python对app页面元素进行封装并设置查找时间操作实例

网友投稿 243 2022-08-29


python对app页面元素进行封装并设置查找时间操作实例

#coding=utf8'''获取顶部元素:推荐、热门、分类、榜单、主播'''from publicLib.findElement import appDriverfrom selenium.webdriver.support.ui import WebDriverWait from publicLib.appInit import appInitclass topBar(object): def __init__(self,appdriver): try: self.driver=appdriver except Exception,e: print "Top Bar ",e def recommandEle(self,timeout=10): try: '''一直查找元素:推荐,默认10秒超时''' recommandEle=WebDriverWait(self.driver,timeout).until(lambda driver:driver.app_find_element_by_text("推荐"),"Can not find recommand element") return recommandEle except Exception,e: print "Find recommane element ",e def hotdoorEle(self,timeout=10): try: '''一直查找元素:热门,默认10秒超时''' hotdoorEle=WebDriverWait(self.driver,timeout).until(lambda driver:driver.app_find_element_by_text("热门"),"Can not find hotdoor element") return hotdoorEle except Exception,e: print "Find hotdoor element ",e def classificationEle(self,timeout=10): try: '''一直查找元素:分类,默认10秒超时''' classificationEle=WebDriverWait(self.driver,timeout).until(lambda driver:driver.app_find_element_by_text("分类"),"Can not find classification element") return classificationEle except Exception,e: print "Find classification element ",e def billboardEle(self,timeout=10): try: '''一直查找元素:榜单,默认10秒超时''' billboardEle=WebDriverWait(self.driver,timeout).until(lambda driver:driver.app_find_element_by_text("榜单"),"Can not find billboard element") return billboardEle except Exception,e: print "Find billboard element ",e def anchorEle(self,timeout=10): try: '''一直查找元素:主播,默认10秒超时''' billboardEle=WebDriverWait(self.driver,timeout).until(lambda driver:driver.app_find_element_by_text("榜单"),"Can not find anchor element") return billboardEle except Exception,e: print "Find anchor element ",edef test(): appdriver=appDriver() appInit(appdriver) recommand=topBar(appdriver) recommand.recommandEle().click() appdriver.quitApp() if __name__=="__main__": test()


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:python获取文件绝对路径解决找不到文件句柄的问题实例(readConfig.py)V1.2
下一篇:Springboot整合FreeMarker的实现示例
相关文章

 发表评论

暂时没有评论,来抢沙发吧~