简体   繁体   English

如何在appium(ios,真实设备)python中滚动半屏

[英]How to scroll in appium (ios, real device) python a half screen

I have a problem, I have to scroll up through calendar, where every day has its own elements (and it may be added or deleted) and find some element for previous date.我有一个问题,我必须向上滚动日历,其中每一天都有自己的元素(并且可能会添加或删除)并找到上一个日期的一些元素。

All I need - to scroll from here to some specific element (let assume that it is not duplicated).我只需要 - 从这里滚动到某个特定元素(假设它没有重复)。

I have tried with-我试过——

self.driver.execute_script("mobile: scroll", {"direction": "up"})

It works but sometimes it over scrolls and element will become invisible again它可以工作,但有时它会滚动,元素将再次变得不可见

Ideal way is to have some method which scrolls from here to some element Or to scroll not the whole screen, but only half of it.理想的方法是有一些方法可以从这里滚动到某个元素,或者不滚动整个屏幕,而只滚动一半。

I have tried the following:我尝试了以下方法:

self.driver.execute_script("mobile: scroll", {"direction": "up", 'element': el})

and

self.driver.execute_script("mobile: scrollTo", {"direction": "up", 'element': el.id})

but it doesn't work.但它不起作用。

  • Selenium (3.0.1)硒 (3.0.1)
  • Appium (1.6.3) Appium (1.6.3)
  • Python 2.7蟒蛇 2.7

I find a solution.我找到了解决办法。 Maybe it will be helpful for someone: For example, in my case it will be (scrollable is only left part of the screen) < self.driver.swipe(window_size['width'] * 0.3, window_size['height'] * 0.15, window_size['width'] * 0.3, window_size['height'] * 0.65)>也许它会对某人有所帮助:例如,在我的情况下,它将是(可滚动仅是屏幕的左侧部分)< self.driver.swipe(window_size['width'] * 0.3, window_size['height'] * 0.15, window_size['width'] * 0.3, window_size['height'] * 0.65)>

Use this, it works.使用这个,它的工作原理。 Put a sleep after that works with your needs.在满足您的需求之后睡一觉。

action = TouchAction(self.driver)
action.long_press(elementToTap).move_to(elementToDrag).release().perform()
  1. you should use scroll without To你应该使用没有 To 的滚动
  2. you will need 'toVisible' beside 'element' in the same dictionary您将需要在同一词典中的“元素”旁边使用“toVisible”
  3. element ID is not the locator ID but it is the id within the session.元素 ID 不是定位器 ID,而是会话中的 ID。 can get it using getId() method可以使用getId()方法获取

self.driver.execute_script("mobile: scroll", {"direction": "up", 'element': el.id, 'toVisible' : 'any non empty text'})

this should work with you这应该和你一起工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Appium:获取设备时间(python,real,device ios) - Appium: getting device time (python, real, device ios) 如何在Python中使用appium滚动 - How to scroll using appium in Python 如何使用Appium在真实设备上从jenkins安装* .apk并运行用python编写的测试? - How can I install *.apk from jenkins on real device with Appium and run tests written in python? 如何使用Appium(最好是python)拍摄原生iOS屏幕截图并自动在设备/模拟器相册中查看它们? - How to take Native iOS Screenshots using Appium (preferably python) and see them in device/simulator Photo album automatically? 如何使用appium和python控制android设备? - How to control android device using appium and python? Appium在iOS(真实设备)上转到URL会遇到“(&#39;Connection aborted.&#39;, BadStatusLine(&quot;&#39;&#39;&quot;,))” - Appium go to URL on iOS (real device) will encounter "('Connection aborted.', BadStatusLine("''",))" 如何在Appium中获取iOS设备显示的最大宽度和高度坐标? - How to get the maximum width and height coordinates of an iOS device display in Appium? 如何使用 Appium 或命令行(无越狱)使用密码解锁 iOS 设备 - How to unlock iOS device with passcode using Appium or Command Line (no jailbreak) 如何使用 Appium 和 Python 在 android 应用程序中滚动列表一次 - How to scroll list once in android application using Appium and Python 如何使用python和appium滚动到未出现在视图中的元素 - How to scroll to an element that does not appear in the view using python and appium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM