无法在appium / python中找到元素

时间:2019-01-30 10:50:38

标签: python automation appium

我正在将Python与Appium一起使用,并且在浏览该应用程序后,Appium找不到下一个元素。我已经通过UI自动器捕获了元素。似乎在我更改活动时找不到该元素。

要澄清:

  1. 启动应用-输入凭据->按发送
  2. 按更多菜单->按用户配置文件->按edituserprofile

当我尝试执行最后一步时,会发生此错误。

[W3C] Calling AppiumDriver.findElement() with args: ["id","com.idem:id/toolbarButton","a491c080-6b0e-4320-815d-edb0f60dd1c1"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 20000 ms for condition
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.idem:id/toolbarButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.idem:id/toolbarButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.idem:id/toolbarButton' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.idem:id/toolbarButton]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.idem:id/toolbarButton' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.idem:id/toolbarButton]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 2855 ms so far
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.idem:id/toolbarButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.idem:id/toolbarButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.idem:id/toolbarButton' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.idem:id/toolbarButton]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.idem:id/toolbarButton' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.idem:id/toolbarButton]
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 5903 ms so far
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.idem:id/toolbarButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.idem:id/toolbarButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.idem:id/toolbarButton' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.idem:id/toolbarButton]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.idem:id/toolbarButton' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.idem:id/toolbarButton]
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 15048 ms so far
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.idem:id/toolbarButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.idem:id/toolbarButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.idem:id/toolbarButton' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.idem:id/toolbarButton]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.idem:id/toolbarButton' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.idem:id/toolbarButton]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 18097 ms so far
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.idem:id/toolbarButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.idem:id/toolbarButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.idem:id/toolbarButton' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.idem:id/toolbarButton]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.idem:id/toolbarButton' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.idem:id/toolbarButton]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[W3C] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
[W3C]     at AndroidDriver.callee$0$0$ (C:\Users\haka1355\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:75:11)
[W3C]     at tryCatch (C:\Users\haka1355\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[W3C]     at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\haka1355\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[W3C]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\haka1355\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[W3C]     at GeneratorFunctionPrototype.invoke (C:\Users\haka1355\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[W3C]     at run (C:\Users\haka1355\AppData\Local\Programs\Appium\resources\app\webpack:\~\babel-polyfill\~\core-js\modules\es6.promise.js:75:1)
[W3C]     at C:\Users\haka1355\AppData\Local\Programs\Appium\resources\app\webpack:\~\babel-polyfill\~\core-js\modules\es6.promise.js:92:1
[W3C]     at flush (C:\Users\haka1355\AppData\Local\Programs\Appium\resources\app\webpack:\~\babel-polyfill\~\core-js\modules\_microtask.js:18:1)
[W3C]     at process._tickCallback (internal/process/next_tick.js:61:11)
[HTTP] <-- POST /wd/hub/session/a491c080-6b0e-4320-815d-edb0f60dd1c1/element 404 27246 ms - 1775
[HTTP] 
[HTTP] --> DELETE /wd/hub/session/a491c080-6b0e-4320-815d-edb0f60dd1c1
[HTTP] {}
[W3C] Calling AppiumDriver.deleteSession() with args: ["a491c080-6b0e-4320-815d-edb0f60dd1c1"]
[BaseDriver] Event 'quitSessionRequested' logged at 1548836645995 (09:24:05 GMT+0100 (W. Europe Standard Time))
[Appium] Removing session a491c080-6b0e-4320-815d-edb0f60dd1c1 from our master session list
[AndroidDriver] Shutting down Android driver
[ADB] Running 'C:\Users\haka1355\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s ce12171c9d44e70d04 shell am force-stop com.idem'
[ADB] Pressing the HOME button
[ADB] Running 'C:\Users\haka1355\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s ce12171c9d44e70d04 shell input keyevent 3'
[AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] Received command result from bootstrap
[UiAutomator] Shutting down UiAutomator
[UiAutomator] Moving to state 'stopping'
[UiAutomator] UiAutomator shut down normally
[UiAutomator] Moving to state 'stopped'
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Running 'C:\Users\haka1355\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s ce12171c9d44e70d04 shell ps'
[ADB] No uiautomator process found to kill, continuing...
[UiAutomator] Moving to state 'stopped'
[Logcat] Stopping logcat capture
[ADB] Running 'C:\Users\haka1355\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s ce12171c9d44e70d04 shell am force-stop io.appium.unlock'
[AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[BaseDriver] Event 'quitSessionFinished' logged at 1548836649208 (09:24:09 GMT+0100 (W. Europe Standard Time))
[W3C] Received response: null
[W3C] But deleting session, so not returning
[W3C] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/a491c080-6b0e-4320-815d-edb0f60dd1c1 200 3217 ms - 14
[HTTP] 

谁能帮助我了解可能出了什么问题?

1 个答案:

答案 0 :(得分:0)

这很明显,我不知道,也许您已经尝试过了。使用等待?例如,尝试使用time.sleep(5),如果测试通过,则只为最后一个元素添加服务员。