【python+appium自动化测试】--uiautomator高级用法:滚动查找页面
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了【python+appium自动化测试】--uiautomator高级用法:滚动查找页面,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2886字,纯文字阅读大概需要5分钟。
内容图文
![【python+appium自动化测试】--uiautomator高级用法:滚动查找页面](/upload/InfoBanner/zyjiaocheng/600/b21c42ccf30b4ab1a1826a2bdd100d43.jpg)
互联网app测试经常遇到的问题:当前页面无法查找到某个元素,需要通过下拉操作到下一页或后续页面才能找到想要的内容
应用场景有:微信朋友圈查找某人发的几天前的朋友圈、微博等
可以使用如下方法:
举个例子,雪球app进入我的---下拉页面查找设置并点击
1 self.driver.find_element_by_android_uiautomator('new UiScrollable(new UiSelector().' 2 'scrollable(true).instance(0)).' 3 'scrollIntoView(new UiSelector().text("设置").' 4 'instance(0));').click()
1 # -*- coding:utf-8 -*- 2 # author:xjw 3 # date=2021/3/4 4 5 from appium import webdriver 6 from appium.webdriver.common.touch_action import TouchAction 7 8 9 class Testappium: 10 def setup(self): 11 desired = { 12 "platformName": "Android", 13 "platformVersion": "6.0.1", 14 "deviceName": "127.0.0.1:7555", 15 "appPackage": "com.xueqiu.android", 16 "appActivity": ".view.WelcomeActivityAlias" 17 } 18 19 self.driver = webdriver.Remote(command_executor="http://127.0.0.1:4723/wd/hub",desired_capabilities=desired) 20 self.driver.implicitly_wait(6) 21 # def teardown(self): 22 # self.driver.quit 23 24 #触屏操作滑动 25 def test_touchaction(self): 26 action=TouchAction(self.driver) 27 window_rect=self.driver.get_window_rect() 28 width=window_rect['width'] 29 height=window_rect['height'] 30 x1=int(width/2) 31 y_start=int(height*1/5) 32 y_end=int(height*4/5) 33 34 action.press(x=x1,y=y_start).wait(200).move_to(x=x1,y=y_end).release().perform() 35 def test_uiautomator(self): 36 self.driver.find_element_by_android_uiautomator('new UiSelector().text("我的")').click() 37 self.driver.find_element_by_android_uiautomator('new UiSelector().textContains("帐号密码登录")').click() 38 self.driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.xueqiu.android:id/login_account")').send_keys('1234') 39 self.driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.xueqiu.android:id/login_password")').send_keys('abcd') 40 self.driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.xueqiu.android:id/button_next")').click() 41 def test_scrolldown(self): 42 self.driver.find_element_by_android_uiautomator('new UiSelector().text("我的")').click() 43 self.driver.find_element_by_android_uiautomator('new UiScrollable(new UiSelector().' 44 'scrollable(true).instance(0)).' 45 'scrollIntoView(new UiSelector().text("设置").' 46 'instance(0));').click()
内容总结
以上是互联网集市为您收集整理的【python+appium自动化测试】--uiautomator高级用法:滚动查找页面全部内容,希望文章能够帮你解决【python+appium自动化测试】--uiautomator高级用法:滚动查找页面所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。