Gna*_*awk 5 python automation scroll appium
嗨,我想知道如何使用 python 在 appium 中滚动
我以前用Java做过,效果非常好。
driver.scrollTo("Destination");
Run Code Online (Sandbox Code Playgroud)
但是我似乎无法在 python 中做同样的事情。我对 python 相当陌生,我尝试过多种滚动方式
我尝试的一种方法是
el1 = self.driver.find_element_by_name('Starting')
el2 = self.driver.find_element_by_name('Ending')
self.driver.scroll(el1, el2)
Run Code Online (Sandbox Code Playgroud)
我尝试的第二种方法是
self.driver.find_element_by_android_uiautomator('new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("DesinationText").instance(0));').
Run Code Online (Sandbox Code Playgroud)
第二种方式滚动一次但没有一直向下滚动,因此抛出 NoSuchElementException。另外,有人可以向我解释一下 UiSelector 中有哪些实例吗?我读了描述,但不太明白
实例:设置搜索条件以按实例编号匹配小部件。
我最终使用了坐标,尽管它不是目前最适合我的解决方案
action = TouchAction(self.driver)
el = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.NAME, loc)))
action.press(el).move_to(x=10, y=-500).release().perform()
Run Code Online (Sandbox Code Playgroud)