question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

XCUITest Element could not be found error

See original GitHub issue

Hi

Before XCUITest (Before IOS 10) I was using below method to find a UI Element in IOS application:

   private void executeIOSAction(IOSObjects mtosElement, ActionType actionType) throws CrashException, ActionNotPossibleException 
  {
      WebElement webElement = null;
      try {
         if (actionType == ActionType.CLICK) { // For finding clickable objects
            if (mtosElement instanceof XCUIElementTypeButton) { 
               // this.turnWifiStatus(true);
               logger.info("Clicking Button:" + mtosElement.getName() + " WithXPath:" + mtosElement.getPathStr());
               XCUIElementTypeButton buttonElement = (XCUIElementTypeButton) mtosElement;
               webElement = driver.findElement(By.xpath(buttonElement.getPathStr()));
               if (webElement != null) {
                  webElement.click();
                  buttonElement.setIsClicked();
             }
    }

But after changing implementation to XCUITest it gives the below error. Does anyone know how can I fix that?

2016-10-13 13:46:55,318 ERROR:  Web Driver Exception:An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 546 milliseconds

Path That I'm Searching: //XCUIElementTypeApplication[1]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeButton[1]

And this is the driver.getPageSource() output of the current Screen:

https://drive.google.com/file/d/0B3eSt3_PT8YXakQwRC1ZOHFDT2c/view?usp=sharing

Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mykola-mokhnachcommented, Feb 12, 2017

The UI tree generated by XCTest is different from the one generated by instruments. So don’t expect same paths or class names to work for both frameworks. Most of the times it is necessary to update locators according to the actual tree. Regarding inspector - the “native” one is currently being developed. Although you can try some alternatives.

1reaction
sonalib10commented, Nov 30, 2016

@jlipps I am unable to locate element appears on a video , though it has Accessibility ID , Label and Type provided. Please help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

element could not be found selenium webdriver mobile
I keep getting the below error message. Selenium::WebDriver::Error::NoSuchElementError: An element could not be located on the page using the ...
Read more >
XCTest UI "failure fetching values… | Apple Developer Forums
My UI testing has started failing when testing 2 sliders on 1 view in my application (All the other work). It's not an...
Read more >
appium-xcuitest-driver - npm
Appium driver for iOS using XCUITest for backend. Latest version: 4.16.5, last published: 8 hours ago. Start using appium-xcuitest-driver in your project by ......
Read more >
Why is XCUITest so Bad - Jon Gabilondo
You will find similar situations in the order of elements. Often, the order of elements as you traverse the UI Tree with the...
Read more >
appium/appium - Gitter
'An element could not be located on the page using the given search parameters. ... Our hybrid app throws the error [debug] [XCUITest]...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found