谢谢您的回复!我用的 python:3.6、appium-desktop:1.7.2、IOS 手机:11.2、Xcode:9.2、MAC 电脑:macOS/10.13.3,日志信息如下。我让代码在很长时间内循环查找,明明看见元素已经出现在界面很长时间了,但是就是找不到元素。。。
[HTTP] --> POST /wd/hub/session/c1b57234-5a05-4c61-aeff-ad676ab2da4b/element {"using":"xpath","value":"//XCUIElementTypeOther[@name=\" 开关\"]","sessionId":"c1b57234-5a05-4c61-aeff-ad676ab2da4b"}
[MJSONWP] Calling AppiumDriver.findElement() with args: ["xpath","//XCUIElementTypeOther[@name=\" 开关\"]","c1b57234-5a05-4c61-aeff-ad676ab2da4b"]
[XCUITest] Executing command 'findElement'
[BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[BaseDriver] Waiting up to 0 ms for condition
[JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/4A370756-5CEB-47D7-B7A6-C00FE4431D04/element] with body: {"using":"xpath","value":"//XCUIElementTypeOther[@name=\" 开关\"]"}
[JSONWP Proxy] Got response with status 200: {"value":{"using":"xpath","value":"//XCUIElementTypeOther[@name=\" 开关\"]","description":"unable to find an element"},"sessionId":"4A370756-5CEB-47D7-B7A6-C00FE4431D04","status":7}
[HTTP] <-- POST /wd/hub/session/c1b57234-5a05-4c61-aeff-ad676ab2da4b/element 500 1915 ms - 164
正常情况下 status 应该是 0,然后输出 [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"找到的元素的序列号"}