Hi I am trying to locate a switch box with method like this:
driver.findElementByXPath(“//android.widget.Switch[contains(@bounds=‘[860,311][1000,392]’)]”).click();
so that I can make the switch box to be set as “ON”.
but the log file shows that failed to find this element. anyone who can help me for this issue?
here is the log file:
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“6521cb85-8c9b-45fe-8ebd-2a6ee664f49e”}
info: ← POST /wd/hub/session/6521cb85-8c9b-45fe-8ebd-2a6ee664f49e/touch/perform 200 325.011 ms - 76 {“status”:0,“value”:true,“sessionId”:“6521cb85-8c9b-45fe-8ebd-2a6ee664f49e”}
info: → POST /wd/hub/session/6521cb85-8c9b-45fe-8ebd-2a6ee664f49e/element {“using”:“xpath”,“value”:“//android.widget.ImageButton[@bounds=‘[860,311][1000,392]’]”}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“xpath”,“selector”:“//android.widget.ImageButton[@bounds=‘[860,311][1000,392]’]”,“context”:“”,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:“//android.widget.ImageButton[@bounds=‘[860,311][1000,392]’]”,“context”:“”,“multiple”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.ImageButton[@bounds=‘[860,311][1000,392]’] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:"Could not find an element using supplied strategy. ",“status”:7}
info: [debug] Condition unmet after 151ms. Timing out.
info: [debug] Responding to client with error: {“status”:7,“value”:{“message”:“An element could not be located on the page using the given search parameters.”,“origValue”:"Could not find an element using supplied strategy. "},“sessionId”:“6521cb85-8c9b-45fe-8ebd-2a6ee664f49e”}
info: ← POST /wd/hub/session/6521cb85-8c9b-45fe-8ebd-2a6ee664f49e/element 500 151.120 ms - 230
info: → DELETE /wd/hub/session/6521cb85-8c9b-45fe-8ebd-2a6ee664f49e {}
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: C:\Android\AndroidSDK\platform-tools\adb.exe -s 022SSE146M005259 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: 22.664
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”:“6521cb85-8c9b-45fe-8ebd-2a6ee664f49e”}
info: ← DELETE /wd/hub/session/6521cb85-8c9b-45fe-8ebd-2a6ee664f49e 200 682.365 ms - 76 {“status”:0,“value”:null,“sessionId”:“6521cb85-8c9b-45fe-8ebd-2a6ee664f49e”}