bug: iOSXCUITestFindBy is not working properly for xpath or iosClassChain
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Current Behavior
I am trying to find the Search Box in the iOS Settings app. This is my locator:
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeSearchField[$name ==[C] 'Search'$]")
private WebElement weSearchText;
The same is working fine with AppiumBy variable.
This is my appium instantiation from log:
When I execute that line, I got this in log:
As you can see, it seems that the logs are sending my element name as iosClassChain instead of my locator:
{"using":"class chain","value":"**/*[
name == "weSearchTextBox"]"}
What am I doing wrong here?
I tried @FindBy similarly for Xpath and that worked fine.
Expected Behavior
The element should ideally get identified properly.
Minimal Reproducible Example
package com.tekioncloud.core.main.mobile.pages; import io.appium.java_client.AppiumBy; import io.appium.java_client.ios.IOSDriver; import io.appium.java_client.pagefactory.iOSXCUITFindBy; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.PageFactory; import java.net.MalformedURLException; import java.net.URL; public class MobileSettingsAppTest { @iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeCell[`label ==[C] 'General'`]") private WebElement weGeneral; private By byGeneral = AppiumBy.iOSClassChain("**/XCUIElementTypeCell[`label ==[C] 'General'`]"); public static void main(String[] args) { try { DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); desiredCapabilities.setCapability("platformName", "iOS"); desiredCapabilities.setCapability("appium:automationName", "XCUITest"); desiredCapabilities.setCapability("appium:bundleId", "com.apple.Preferences"); desiredCapabilities.setCapability("appium:deviceName", "iPhone XR"); desiredCapabilities.setCapability("appium:newCommandTimeout", "0"); desiredCapabilities.setCapability("appium:platformVersion", "12.1"); desiredCapabilities.setCapability("appium:udid", "00008020-001B044C0193802E"); desiredCapabilities.setCapability("appium:waitForQuiescence", false); desiredCapabilities.setCapability("appium:wdaLocalPort", "8100"); IOSDriver iDriver = new IOSDriver(new URL("http://0.0.0.0:4723"), desiredCapabilities); iDriver.setSetting("useFirstMatch", true); MobileSettingsAppTest mobileSettingsAppTest = new MobileSettingsAppTest(); PageFactory.initElements(iDriver,mobileSettingsAppTest); mobileSettingsAppTest.weGeneral.click(); // iDriver.findElement(mobileSettingsAppTest.byGeneral).click(); } catch (MalformedURLException e) { throw new RuntimeException(e); } } }
Environment
- Operating system:
- If running via
appium
CLI…- Appium CLI version (output of
appium --version
): 2.0.0-beta.44 - Node.js version (output of
node --version
): v18.7.0 npm
version (output ofnpm --version
): 8.18.0- Last
appium
version which did not exhibit the problem: Didn’t try this previously
- Appium CLI version (output of
- If running Appium Desktop, its version: NA
- Appium driver(s) and their version(s): xcuitest@4.11.1
- Appium plugin(s) and their version(s): NA
- Platform and version under test: iOS 16.1.1
- Real device or emulator/simulator: iPhone XR real device
Link to Appium Logs
No response
Futher Information
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
java - @iOSXCUITFindBy Annotations don't work but the same ...
When I am using below its working fine, but when I am using pagefactory annotations. driver.findElement(By.xpath("//*[@class='UIAButton'][2]")).
Read more >@iOSXCUITFindBy Annotations don't work but the same code ...
@iOSXCUITFindBy Annotations don't work but the same code works when I use driver.findElement(By.accessibilityid) or even xpath · Issues/Bugs.
Read more >appium/appium - Gitter
Hi all, I see @iosxcuitfindby annotation not working for my scripts..I used all attributes like xpath, class chain, accessibility ld. But If I ......
Read more >Integrate PageFactory with PageObjectModel in appium
... with PageObjectModel in appium | @AndroidFindBy | @ iOSXCUITFindBy ... An error occurred while retrieving sharing information.
Read more >Even after providing proper xpath for element on mobile ...
following is the errror i get " Error msg is: An element could not be located on the page using ... 'XPATH' with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like java client lib unexpectedly changes the locator to CSS type? Are you sure the most recent version of it is used?
Yeah, its working now. Thanks @mykola-mokhnach.