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中的方法【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!