[英]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.但它不起作用。
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()
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.