def Element_Scroll_To_Visibility(self, locator, fromX, fromY, toX, toY,
by=MobileBy.IOS_PREDICATE, model=None): # 将元素滚动到可见区域
"""
将不可见元素滚动到可见区域
:param locator: 元素表达式
:param fromX: 起始位置X坐标倍数
:param fromY: 起始位置Y坐标倍数
:param toX: 终点位置X坐标的倍数
:param toY: 终点位置Y坐标的倍数
:param by: 元素定位方式
:param model: 截图命名默认为None
:return:
"""
try:
logging.info('开始滚动操作,一直到元素可见')
while True:
try:
WebDriverWait(self.driver, 1).until(EC.
visibility_of_element_located(
(by, locator)))
break
except:
pass
size = self.driver.get_window_size()
self.driver.execute_script("mobile:dragFromToForDuration",
{"duration": 0.5, "element": None, "fromX": size['width'] * fromX,
"fromY": size['height'] * fromY, "toX": size['width'] * toX,
"toY": size['height'] * toY})
except:
self._save_screenShot(model)
logging.error('获取文本内容失败')
raise
2385
21
508
582
375
8
238
647
欢迎来到testingpai.com!
注册 关于