python对app页面元素进行封装并设置查找时间操作实例
2017-03-27 18:48
851 查看
#coding=utf8 ''' 获取顶部元素: 推荐、热门、分类、榜单、主播 ''' from publicLib.findElement import appDriver from selenium.webdriver.support.ui import WebDriverWait from publicLib.appInit import appInit class 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 ",e def test(): appdriver=appDriver() appInit(appdriver) recommand=topBar(appdriver) recommand.recommandEle().click() appdriver.quitApp() if __name__=="__main__": test()
相关文章推荐
- python对app页面元素进行封装并设置查找时间操作实例
- python对app页面元素进行封装并设置查找时间操作实例
- python对app页面元素进行封装并设置查找时间操作实例
- Python操作Redis之设置key的过期时间实例代码
- Python操作Redis之设置key的过期时间
- selenium设置元素发现超时等待时间-python
- python封装安卓查找元素方法V1.0
- jQuery参考实例 1.5 对jQuery封装后的元素集进行过滤
- 二分法的应用----------利用随机类生成数组,并用二分法对数组的元素进行查找以及插入操作
- jQuery元素属性操作实例(设置、获取及删除元素属性)
- 自定义类封装数组,并对数组进行CRUD操作;有序数组的实习与查找
- Python 字符串(三)-字符串操作实例(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- [Selenium] 操作页面元素等待时间
- JS封装cookie操作函数实例(设置、读取、删除)
- 浅谈Python中用datetime包进行对时间的一些操作
- .net实例:ASP.net在页面所有内容生成后、输出内容前对页面内容进行操作
- python实例编写(1)--浏览器操作,元素操作
- CSS+HTML实例集合四,checkbox多选框的操作(全选等),select获取option的value和其对应的选项,select获取选中项的value值进行设置,select的二级联动菜单
- JQuery 将选择器进行缓存 便于大量操作表格或其他页面元素
- python对list中的每个元素进行某种操作