可以使用如下方法:
举个例子,雪球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.quit23 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高级用法:滚动查找页面所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)