appium\selenium+python 滑动屏幕直至某元素出现

appium
获取屏幕宽高:
width = driver.get_window_size()['width']
height = driver.get_window_size()['height']

while循环10次
i=0
while i < 10:
    try:
        driver.find_element_by_xpath("path").click()#尝试点击元素
        break
    except Exception as e:
        driver.swipe(width/2,height*0.8,width/2,height*0.2)#滑动屏幕
        i=i+1

selenium

element = self.driver.find_element_by_xpath(position)
elements = self.driver.find_element_by_xpath(position)
i=0
while i < 10:
    try:
        elements[no].click()
        break
    except Exception as e:
        ScripeFunc.scrollIntoWindowY(self)
        i = i + 1
        if i==10:
            print("no element")
     

你可能感兴趣的:(测试开发)