iOS+python+appium自动化测试当通过id、name或者xpath无法定位元素时解决方案

iOS自动化测试过程中,经常遇到无法通过d、name或者xpath定位元素的问题,那么该如何解决这个问题呢?

使用以下两种方式均可:

1、TouchAction(self.driver).press(x=0, y=466).release().perform()
    使用该方法时需要导入TouchAction()方法,即:
    from appium.webdriver.common.touch_action import TouchAction
    那么坐标是如何获取的呢?
    开启appium,连接到app,然后点击具体元素可以显示某个元素的具体坐标x,y
 
2、self.driver.tap([(249,466)],500)
     使用self.driver.tap([(249,466)],500)为什么有时候还是定位不到元素呢?解决方案如下:
     在self.driver.tap([(249,466)],500)前面加上休眠时间,即:
     time.sleep(1)
     self.driver.tap([(249,466)],500)
     如何获取坐标呢?
     同1中的方法

猜你喜欢

转载自www.cnblogs.com/lxmtx/p/12538657.html