-
-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[8.0.0 Beta 2] PageFactory still not working with Java 17 #1619
Comments
I think it relates to cglib/cglib#191 |
I am having the same issue |
I am having the same issue also. |
Is there a workaround for this? |
same issue here in 8.0.0.
|
I'm still facing the issue with It doesn't work and still same error as #1575
|
i have the same issue |
Running into the same issue Edit: I got it working, but I can't find any documentation on if this is how it is supposed to work now. If this is how the PageFactory is supposed to work, I have questions. The old way of doing it is something like:
The new way of doing it seems to be something like:
If this is indeed the new way to do this in Appium java-client 8 and java 18, this seems to remove the ability to have a FindBy for both Android and iOS populate the same WebElement variable name, depending on if I am testing iOS or Android. |
@cameronbrandcoders - In the above new way of doing how can we use the same WebElement for ios and android, the old way - @AndroidFindBy(id = "AndroidButtonID") @mykola-mokhnach - could you please help me on this issue, I am actually running in a loop and unable to find the root cause! Completely Stuck! When I run the individual cucumber features, it works perfectly fine but when I try to run it through the test runner it throws the same error - java.lang.ExceptionInInitializerError Guys does anybody have a solution for the above issue? appium java-client - 8.0.0 |
@cnerkar1859 |
@taimoor8152 |
Im getting similar issue and in similar environment:
Appium: 2.0.0-beta.44 error similar to reported above: |
@sinapot Please install java 11 first and this error will be removed automatically. If you are still facing any issue let me know. |
@taimoor8152 @mykola-mokhnach @AndroidFindBy(id="yyy") By using @AndroidFindBy or @AndroidBy, the element identifier initialization is not happening. => org.openqa.selenium.NoSuchElementException: Can't locate an element by this strategy: by id or name "backgroundImage" if i use @findby the element identifier is picked correctly. However, this restrict the execution in Android and iOS => |
@benz-philip01 Please install java 11.0 not 11.0.11. If you are using eclipse in Mac |
@taimoor8152 Not sure how to point java version specifically to 11.0. benzmathewphilip@Benzs-MacBook-Pro ~ % jenv versions
benzmathewphilip@Benzs-MacBook-Pro ~ % java -version |
@benz-philip Can you please try to uninstall the java 11.0.11 then install java 11.0 again. |
Thanks @taimoor8152 . Let me try |
@taimoor8152 - I remember posting here that it has resolved my issue but i have started seeing this issue again |
I had the same issue as you. How was your issue going? Is it resolved? |
Can you share me why java 11? Is there any higher version of java if it works instead of java 11? |
@taimoor8152 - It started working for me again but for some reason, I had to stop the test runner in between & when I tried to run it again it started throwing the same error |
Hi @taimoor8152, When i debug in to my script, it says null element, pls see below "testButton". Can you share your thought on that? |
@Hungleminh Can you please make |
I didnot use testng. Is there any related problem with that? |
Which testing framework are you working with then?? |
Appium, java gauge, java |
@Hungleminh You need to do some work with testng as i am experienced with that only. I am not sure what your experience is but you i have worked with test ng |
Was there ever an official fix for this? Or accepted workaround? Also would like to know the “right” way to handle page factory classes for Appium purposes. I’d love to define locators for Android and iOS in a single page class. But it seems that may be no longer supported? |
The decision for Java 17:
|
wrote a blog post on how to resolve this issue: |
Hi I am still getting the same issue in |
I'm also stuck with this issue on APPIUM 2.0 and JDK18. For now on, best solution is use @FindALL/@findby |
Thank you God |
Hi All, if still anyone facing same issue where Page Factory is not identifying the mobile elements. I have found that solution for that issue, please use as below and let me know if this works. Compatibility Version: Sample Code:
So far, I am able to identify both android and iOS elements and working fine for me with above combination. Please let me know if this works. |
FYI I also came across this issue recently. I couldn't find any suitable documentation relating to this change and I was at wits end. Turns out, after lots of trial & error, you can do the following:
The 'thing' though I'm seeing is that appium still looks for both platform locators even if you're running on 1 platform. Which mainly means the test takes longer and your duration will be impacted. I haven't used this method too much but will be keen to see others thoughts in future. |
@mykola-mokhnach @ayuryev
I tested 8.0.0 Beta 2 which has a fix for #1575 and I have got the same cglib error with Java JDK 17.0.1 which is the LTS.
Am I missing something here?
Please find the exception log below. I get this exception for Selenium's PageFactory.initElements(driver, this) command;
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:209)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.access$000(AppiumFieldDecorator.java:61)
at io.appium.java_client.pagefactory.AppiumFieldDecorator$1.proxyForLocator(AppiumFieldDecorator.java:100)
at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:63)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:147)
at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:111)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:103)
at base.BaseTest.(BaseTest.java:98)
at pages.LoginPage.(LoginPage.java:9)
at com.qa.tests.LoginTests.beforeMethod(LoginTests.java:48)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)
at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:700)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:527)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:794)
at org.testng.TestRunner.run(TestRunner.java:596)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:28)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:418)
at org.testng.internal.thread.ThreadUtil.lambda$execute$0(ThreadUtil.java:64)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @6442b0a6
at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:464)
at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:339)
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
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @6442b0a6
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at net.sf.cglib.core.ReflectUtils$1.run(ReflectUtils.java:61)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at net.sf.cglib.core.ReflectUtils.(ReflectUtils.java:52)
at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:243)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332)
... 51 more
The text was updated successfully, but these errors were encountered: