Can you identify the source of the error in this case?
Click works for: iosDriver.findElement(AppiumBy.accessibilityId("Switches")).click();
But when @iOSXCUITFindBy Annotations is used then it fails with org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
Below is the Click call made to Dashboard screen new Dashboard(iosDriver).clickOnSwitches();
After using PageFactory.initElements(new AppiumFieldDecorator(driver, Duration.ofSeconds(sec)), this);
…its now throwing below error:
java.lang.ExceptionInInitializerError
at io.appium.java_client.pagefactory.utils.ProxyFactory.getEnhancedProxy(ProxyFactory.java:53)
at io.appium.java_client.pagefactory.utils.ProxyFactory.getEnhancedProxy(ProxyFactory.java:33)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.proxyForAnElement(AppiumFieldDecorator.java:208)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.access$000(AppiumFieldDecorator.java:60)
at io.appium.java_client.pagefactory.AppiumFieldDecorator$1.proxyForLocator(AppiumFieldDecorator.java:99)
at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:63)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:146)
at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:111)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:103)
at com.example.pages.ios.Dashboard.<init>(Dashboard.java:16)
I made the change in pom.xml as well for execution in pipelines.
I made both changes from the screenshot, and page-factory is working as expected. Glad I don’t have to switch between JDK versions.