Appium中常用查找控件的方法
来源:互联网 发布:python上位机 编辑:程序博客网 时间:2024/06/05 11:40
曾经由于一些特殊的原因搁置了,有很多想法,并未去实现,准备花点时间把基于Appium的UI自动化项目重写一下,一方面是以前写的过于耦合,也有一些特殊的问题没有解决,如:不同手机有不同的权限弹框、失败重试机制、校验脚本失败是由于应用质量还是脚本本身原因等。学的多不如学的精,意义不外如是也~
这是以前整理的Appium中常用的操作控件的方法,后续会继续补充…
1.通过文本定位
driver.findElementByAndroidUIAutomator("new UiSelector().text(\"反馈天气\")").click();
2.通过列表index定位
List<WebElement> listReport = driver.findElementsByClassName("android.widget.TextView");// 获取TextView的所有元素 WebElement targetReport = listReport.get(4);// 获取列表中第四个Textview,即“阴” targetReport.click();
3.通过Xpath定位
driver.findElementByXPath( "//android.widget.Button[@resource-id=\"com.moji.mjweather:id/btn_weather_feedback_publish\"]").click(); Thread.sleep(2000);driver.findElementByXPath("//android.widget.TextView[@text=\"使用其他方式登录\"]").click();
4.输入文字
List<WebElement> textFieldsList = driver.findElementsByClassName("android.widget.EditText"); //textFieldsList.get(0).clear(); textFieldsList.get(0).sendKeys("15527913638"); textFieldsList.get(1).sendKeys("12345678");// 另一种输入方法,与List效果一致 /* * driver.findElement(By.id( * "com.moji.mjweather:id/et_login_input_account")).sendKeys( * "15527913638"); driver.findElement(By.id( * "com.moji.mjweather:id/et_login_input_password")).sendKeys("123456"); */
5.校验文案是否展示
// wait login success Assert.assertTrue(driver.findElement(By.name("好友动态")).isDisplayed());
6.截屏
snapshot((TakesScreenshot) driver, "时景页面.png");
0 0
- Appium中常用查找控件的方法
- Appium 关于 appium 的原生控件的 xpath 定位问题及常用方法
- appium,智能查找方法
- VB中查找控件的方法
- Appium定位控件的多种方法
- appium一些常用方法的封装
- appium一些常用方法的封装
- WPF中查找子控件、父控件的方法
- Appium常用方法总结
- Appium常用方法介绍
- appium常用方法
- Appium 常用方法
- appium常用方法
- Android控件中pop_menu的常用方法
- python写appium测试用例找控件的方法总结
- Appium API常用方法解释
- 浅析jQuery中常用的元素查找方法总结
- 浅析jQuery中常用的元素查找方法总结
- 一、SpringBoot精要
- Java面试题
- linux命令学习4
- Unity3D 工程机械以及常见机构铰链,关节绑定 插件
- 为什么做java的web开发我们会使用struts2,springMVC和spring这样的框架?
- Appium中常用查找控件的方法
- 内存对齐的全面剖析
- Android启动页面
- 如何编写jQuery插件
- Android O 8.0 新功能预览
- Linux 下的进程初步
- const的常见用法
- 计算几何模板
- 数据库事务