学习 find_element_by_android_uiautomator 来定位,但是出错:
报错信息:
Error
Traceback (most recent call last):
File "F:\autotest\app-yggdrasil\code\source\Keyword\AppTest\loginJinlu.py", line 42, in test_login
self.driver.find_element_by_android_uiautomator("new UiSelector().content-desc(\"元素contentdesc\")")
File "C:\Users\vip\AppData\Roaming\Python\Python27\site-packages\appium\webdriver\webdriver.py", line 110, in find_element_by_android_uiautomator
return self.find_element(by=By.ANDROID_UIAUTOMATOR, value=uia_string)
File "C:\Users\vip\AppData\Roaming\Python\Python27\site-packages\selenium\webdriver\remote\webdriver.py", line 712, in find_element
{'using': by, 'value': value})['value']
File "C:\Users\vip\AppData\Roaming\Python\Python27\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "C:\Users\vip\AppData\Roaming\Python\Python27\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
WebDriverException: Message: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.
代码:
self.driver.find_element_by_android_uiautomator("new UiSelector().content-desc(\"元素contentdesc\")")
元素信息:
appiumlog:
info: Shutting down appium session
> info: [debug] Pressing the HOME button
> info: [debug] executing cmd: E:\android\android-sdk-windows\platform-tools\adb.exe -s b3413520 shell "input keyevent 3"
> info: [debug] Stopping logcat capture
> info: [debug] Logcat terminated with code null, signal SIGTERM
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
> info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"OK, shutting down","status":0}
> info: [debug] [BOOTSTRAP] [debug] Closed client connection
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
> info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
> info: [debug] [UIAUTOMATOR STDOUT] Time: 21.076
> info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
> info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
> info: [debug] UiAutomator shut down normally
> info: [debug] Cleaning up android objects
> info: [debug] Cleaning up appium session
> info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"3f17452f-760b-4d8c-8421-b5c8606be9fd"}
> info: <-- DELETE /wd/hub/session/3f17452f-760b-4d8c-8421-b5c8606be9fd 200 750.192 ms - 76 {"status":0,"value":null,"sessionId":"3f17452f-760b-4d8c-8421-b5c8606be9fd"}
在 python 里面不能用这个方法定位吗?望赐教~~