python-client icon indicating copy to clipboard operation
python-client copied to clipboard

🐞 bug: <title> Matched W3C error code 'no such element' to NoSuchElementError

Open KaiJia2017 opened this issue 4 months ago • 5 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Appium Version

appium:2.19.0 xcuitest:9.4.0 appium-Python-Client:5.1.1 ideviceinfo 1.3.0-282-g796d09d ideviceinstaller 1.1.1

Appium Host Type

Command Line

Are you using Appium components not maintained by the Appium team?

No response

Is this issue reproducible using the latest components?

  • [x] I confirm the issue is still reproducible with the latest component versions

Current Behavior

An error occurs when executing the Back method.

Expected Behavior

My code is protected by try except. Even if EC.visibility_of_element_located(("accessibility id", "Back") cannot find the element, is it possible to not have an exception? How can I modify the code?

Appium Log

appium_00008140-000134602402201C.log

Environment Details

  • Debug details (appium --show-debug-info):
  • Last component version(s) which did not exhibit the problem:
  • Platform and version of device under test:
  • Real device or emulator/simulator:

Minimal Reproducible Example

def back(self): try: self.reset_consecutive_swipe_time() WebDriverWait(self.driver, 3).until( EC.visibility_of_element_located(("accessibility id", "Back")) ).click() except: self.driver.execute_script("mobile: swipe", {"direction": "right"})

Further Information

No response

KaiJia2017 avatar Aug 07 '25 03:08 KaiJia2017

Now the process is completely stuck because of this step error.

KaiJia2017 avatar Aug 07 '25 04:08 KaiJia2017

self.driver.execute_script("mobile: swipe", {"direction": "right"}) Is this a problem with the execution?

KaiJia2017 avatar Aug 07 '25 07:08 KaiJia2017

What is the page source when you call accessibility id with Back:

[38;5;36m[9f84771b][0m[38;5;98m[XCUITestDriver@5051][0m Matched '/element' to command name 'findElement'
[38;5;36m[9f84771b][0m[38;5;98m[XCUITestDriver@5051][0m Proxying [POST /element] to [POST http://127.0.0.1:8100/session/7EA09726-9801-4A91-9B6C-0BFED54DAF43/element] with body: {"using":"accessibility id","value":"Back"}
[38;5;36m[9f84771b][0m[38;5;98m[XCUITestDriver@5051][0m Got response with status 404: {"value":{"error":"no such element","message":"unable to find an element using 'accessibility id', value 'Back'","traceback":"(\n\t0   WebDriverAgentLib                   0x00000001038ca58c FBNoSuchElementErrorResponseForRequest + 252\n\t1   WebDriverAgentLib                   0x00000001038ca3b4 +[FBFindElementCommands handleFindElement:] + 316\n\t2   WebDriverAgentLib                   0x000000010388c400 -[FBRoute_TargetAction mountRequest:intoResponse:] + 168\n\t3   WebDriverAgentLib                   0x00000001038752f8 __37-[FBWebServer registerRouteHandlers:]_block_invoke + 408\n\t4   WebDriverAgentLib                   0x00000001038af268 -[RoutingHTTPServer handleRoute:withRequest:response:] + 168\n\t5   WebDriverAgentLib                   0x00000001038afd58 __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 64\n\t6   libdispatch.dylib                   0x000000019c26efa8 C05E486D-81F2-367E-9CE1-E14573C4C268 + 16296\n\t7   libdispatch.dylib                   0x...
[38;5;36m[9f84771b][0m[38;5;123m[W3C][0m Matched W3C error code 'no such element' to NoSuchElementError
[38;5;36m[9f84771b][0m[38;5;98m[XCUITestDriver@5051][0m Waited for 194 ms so far

KazuCocoa avatar Aug 07 '25 08:08 KazuCocoa

My code is protected by try except. Even if EC.visibility_of_element_located(("accessibility id", "Back") cannot find the element, is it possible to not have an exception? How can I modify the code?

If you meant you won't raise an exception for find_element, find_elements will help. It will return an empty string if no elements are available. Asking such a question in https://discuss.appium.io/ will also helpful

KazuCocoa avatar Aug 07 '25 08:08 KazuCocoa