Posted on 2013-06-07 14:59
pts 阅读(679)
评论(0) 编辑 收藏 所属分类:
Python
def getTdOfTableContains(self,table,conText):
#add 20130607 by sho
#find first td in table and td's innertext contains conText
for cell in table.cells:
if conText in cell.innertext:
return cell
return None
def getTrOfTableContains(self,table,conText):
#add 20130607 by sho
#find first tr in table and tr's cells contains conText
td=self.getTdOfTableContains(table,conText)
if td:
return self.getElementParent(td)
else:
return None
测试代码:
*** 远程解释器再初始化了 ***
>>> from PAM30 import PAMIE
>>> ie=PAMIE("http://1.1.1.1/query/itemQueryAction.do?method=jumpToSingleItemTrackQuery")
>>> ie.setTextBox("itemno","1191590659011")
True
>>> ie.submitForm("itemQueryForm")
True
>>> tb4=ie.findElement("table","classname","table4")
>>> tr_sj=ie.getTrOfTableContains(tb4,u"收寄")
>>> print tr_sj.outerhtml