Appium脚本(2):元素检测
2024-08-30 07:44:09
场景:
有的按钮在第一次打开时显示,之后就不显示了,如更新提示、特性介绍等,面对这样的场景写了如下脚本,增加脚本的复用性。
no_element_exception_2.py
from appium import webdriver
from selenium.common.exceptions import NoSuchElementException desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['deviceName'] = '127.0.0.1:62001'
desired_caps['platforVersion'] = '5.1.1' # 真机配置
# desired_caps['deviceName']='MX4'
# desired_caps['platforVersion']='5.1'
# desired_caps['udid']='750BBKL22GDN' # desired_caps['app'] = r'C:\python_dir\apps\kaoyan3.1.0.apk'
desired_caps['appPackage'] = 'com.tal.kaoyan'
desired_caps['appActivity'] = 'com.tal.kaoyan.ui.activity.SplashActivity' # 重置开关,默认false,默认每次如第一次安装好的状态
desired_caps['noReset'] = 'True' driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.implicitly_wait(5) def check_cancelBtn():
print("check cancel button")
try:
cancelBtn = driver.find_element_by_id('android:id/button2')
except NoSuchElementException:
print("no cancel button")
else:
cancelBtn.click()
driver.implicitly_wait(2) def check_skipBtn():
print("check skip button")
try:
skipBtn = driver.find_element_by_id('com.tal.kaoyan:id/tv_skip')
except NoSuchElementException:
print("no skip button")
else:
skipBtn.click()
driver.implicitly_wait(2) check_cancelBtn()
check_skipBtn()
driver.find_element_by_id('com.tal.kaoyan:id/login_register_text').click()
driver.implicitly_wait(5)
最新文章
- ABP框架 - 时间
- csharp: Importing or Exporting Data from Worksheets using aspose cell
- Elastic search入门
- python paramiko ssh.exec_command()启动tomcat服务器应用进程失败问题解决方法- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this progr
- shader学习路线
- Apache Struts 跨站脚本漏洞
- OMCS开发手册(01) -- 多媒体设备管理器
- patch 28729262
- LeetCode.数字转罗马数字
- (二分查找 拓展) leetcode278. First Bad Version
- Navicat premium 破解步骤
- webapi 统一处理时间格式
- 连接mysql数据库,创建用户模型
- Java之基础学习(数据类型、运算符、分支语句和循环语句)
- xml解析 使用dom4j操作xml
- 020 $.each的使用
- Error:..\FreeRTOS\portable\RVDS\ARM_CM3\port.c,378 Error:..\FreeRTOS\portable\RVDS\ARM_CM3\port.c,378 Error:..\FreeRTOS\portable\RVDS\ARM_CM3\port.c,378 Error:..\FreeRTOS\tasks.c,2806
- 冲刺Two之站立会议1
- Graham求凸包模板
- 如何解决“当前上下文中不存在名称“XXXXXXXX””的问题
热门文章
- go语言笔记1
- 个人第五次作业-alpha2测试
- POI IndexedColors 编码 与 颜色 对照
- Codeforces C. Elections(贪心枚举三分)
- C# 退出应用程序的几种方法
- JavaWeb报错:java.sql.SQLException: Invalid value for getInt()
- FTP服务FileZilla Server上传提示550 Permission denied
- docker容器配置加速器
- [VSCode] Adding Custom Syntax Highlighting to a Theme in VSCode
- 20199302《Linux内核原理与分析》第十二周作业