Thank for the answer, but I’ve tried to put quotes in different ways and it doesn’t work. I also tried using this locator via driver.findElement(AppiumBy.iOSClassChain()) and the click worked, so it looks like the locator is properly and it’s something else
As I mentioned earlier, I placed this locator in the .findElement method and it works, so I don’t think the locator is the issue. However, I have also tried using with ’ and `. It didn’t work
I also noticed that when tests fail, an error occurs that the element Proxy element for: DefaultElementLocator ‘by id or name “signButton”’ is not found, as if the locator is invisible for the test and it sees only the name of the WebElement, that is, signButton. So perhaps I somehow put the annotation wrong?
Appium logs:
13:55:47.273 [main] ERROR base.TestBase - Can’t click element: Proxy element for: DefaultElementLocator ‘by id or name “signButton”’
[HTTP] → POST /session/f8bc1d5f-2cbe-4075-85db-d9be232f6836/element
[HTTP] {“using”:“css selector”,“value”:“#signButton”}
public PageBase(AppiumDriver appiumDriver) {
PageFactory.initElements(driver, this);
driver = appiumDriver;
}
But if I add AppiumFieldDecorator I will catch ExceptionInInitializerError because my Java version is 19.0.1. Can this be fixed somehow without downgrading to java 11?
[AppiumDriver@cc73] New XCUITestDriver session created successfully, session cca027a4-e946-4374-89e2-88e37938fe88 added to master session list
[AppiumDriver@cc73] Promoting 1 sessionless plugins to be attached to session ID cca027a4-e946-4374-89e2-88e37938fe88
[HTTP] <-- POST /session 200 45554 ms - 956
[HTTP]
[HTTP] --> POST /session/cca027a4-e946-4374-89e2-88e37938fe88/execute/sync
[HTTP] {“script”:“mobile: configureLocalization”,“args”:[{“keyboard”:{“layout”:“QWERTY”,“name”:“en_US”,“hardware”:“Automated”}}]}
[AppiumDriver@cc73] Plugins which can handle cmd ‘execute’: images
[AppiumDriver@cc73] Plugin images is now handling cmd ‘execute’
[AppiumDriver@cc73] Executing default handling behavior for command ‘execute’
[HTTP] <-- POST /session/cca027a4-e946-4374-89e2-88e37938fe88/execute/sync 200 899 ms - 14
[HTTP]
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 base.PageBase.(PageBase.java:52)
at steps.AuthSteps.(AuthSteps.java:13)
at tests.A03001.WithdrawAccountTenge.withdrawAccountTenge(WithdrawAccountTenge.java:17)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:677)
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:962)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:806)
at org.testng.TestRunner.run(TestRunner.java:601)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:433)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:427)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:387)
at org.testng.SuiteRunner.run(SuiteRunner.java:330)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
at org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng.TestNG.run(TestNG.java:1067)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:105)
Caused by: java.lang.IllegalArgumentException
at org.objectweb.asm.ClassVisitor.(ClassVisitor.java:75)
at net.sf.cglib.core.DebuggingClassWriter.(DebuggingClassWriter.java:49)
at net.sf.cglib.core.DefaultGeneratorStrategy.getClassVisitor(DefaultGeneratorStrategy.java:30)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332)
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96)
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94)
at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:294)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:221)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:174)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:153)
at net.sf.cglib.proxy.Enhancer.(Enhancer.java:73)
… 39 more
Good news! In java-client 8.5.1 the bug with page factory initialization was fixed, now all annotations work correctly (cglib replaced with with bytebuddy) java-client 8.5.1 changelog