Appium对iOS的几种定位方法

  1. 一般定位用xpath,当xpath不好用的时候,我们可以用下面两种专用与ios的定位方法:
    driver.find_element_by_ios_predicate("type=='XCUIElementTypeSecureTextField' AND value=='密码'")
    或者
    driver.ios_class_chain('/XCUIElementTypeButton[label == "nav back"]')

  2. 当运行程序点击控件时,有时候,无法完成点击,如:

driver.find_element_by_xpath().click()
我们可以用页面元素的坐标完成定位点击,如:
driver.tap([(961, 308)], 500)
原因是因为click无法完成点击,用tap。

  1. 用Appium的自动录制功能,找到控件的坐标;

from appium.webdriver.common.touch_action import TouchAction
TouchAction(self.driver).press(x=491, y=589).move_to(x=491, y=589).release().perform()

猜你喜欢

转载自blog.51cto.com/34526667/2540738