【发布时间】:2020-07-28 11:10:39
【问题描述】:
Android 上的 Appium + Python - 滚动 我有一个应用程序来自动化测试。场景如下所示:
我点击日期选择器 > 日历出现
我点击年份 > 出现年份列表
我想滚动到“1993”可见
“1993”年在屏幕上不可见,我想继续滚动直到它出现。我试过了
TouchAction(driver).press(x=746, y=1351).move_to(x=755, y=588).release().perform()
^但我不想使用坐标,而且我必须重复该行数次。
def set_year(self):
visibility = self.driver.find_element(By.XPATH, "//android.widget.TextView[@text='1993']").is_displayed()
while not visibility:
TouchAction(self.driver).press(x=746, y=1351).move_to(x=755, y=588).release().perform()
visibility = self.driver.find_element(By.XPATH, "//android.widget.TextView[@text='1993']").is_displayed()
else:
print("not found")
^但它一直在抛出 selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters 错误,因为正如我所说,它不可见
最好的方法是什么?
el = self.driver.find_element_by_xpath(<your_xpath>) driver.execute_script("mobile: scrollTo", {"element": el.id})
^这个给我一个错误,说元组没有id
【问题讨论】:
标签: python selenium-webdriver appium