java-client
java-client copied to clipboard
Unable to run the appium test with junit test runner using 2.0.0-beta.40 Appium Server
The problem
I ran into this issue recently where-in am trying to run my suite through test runner but unfortunately am getting java.lang.ExceptionInInitializerError, Instead i am able to run the individual feature file successfully one by one, I tried to downgrade appium server but didn't help, a similar issue has been raised by multiple people but not specific with the JUnit test runner ( https://github.com/appium/java-client/issues/1619 ), I am able to start the appium server but it fails at the
PageFactory.initElements(new AppiumFieldDecorator(driver), this); with java.lang.ExceptionInInitializerError
Environment
- Appium version (or git revision) that exhibits the issue: 2.0.0-beta.40
- Last Appium version that did not exhibit the issue - I don't remember I have tried with test runner before
- Desktop OS/version used to run Appium: v1.22.3
- Node.js version (unless using Appium.app|exe): v18.7.0
- Npm or Yarn package manager: 8.15.0
- Mobile platform/version under test: android ( same issue occurs on ios as well )
- Real device or emulator/simulator: real device
- Appium CLI or Appium.app|exe:
Details
I am able to run the individual cucumber features successfully but can't run only with the Junit test runner, I compared the capabilities as well but not sure what's wrong, I could really use expertise from this group to help me out on this issue, I am completely stuck at this moment.
Link to Appium logs
(https://gist.github.com/cnerkar1859/1eddb9ed212d3053839307525007f708)
Code To Reproduce Issue [ Good To Have ]
public class MyVfLoginPage {
public MyVfLoginPage(AppiumDriver driver) { this.driver = driver; PageFactory.initElements(new AppiumFieldDecorator(driver), this); // It's failing while iniatilising the elements }
@AndroidFindBy(xpath = "//*[@resource-id='signin_txtUsername']")
@iOSXCUITFindBy(id = "signin_txtUsername")
public WebElement txtUsername;
} }
NOTE - If I change the above code to
using PageFactory.initElements(driver, this); with @FindBy it goes through successfully
I have the same issue with java 17. Is there any solution to resolve it, so I can use both annotations AndroidFindBy and iOSXCUITFindBy? Appium: 2.0.0-beta.44 Appium Java client: 8.2.0
@davudmurtazin: This is my observation, Initially --- I was on Appium Java client 8.0.0 with Java 8 and I was getting the above error, So I updated to java 11 with appium 8.2.0 and it worked, but also tried java 8 with 8.2.0 and it worked, So as per my analysis this won't be an issue with java, check if you have multiple java installed and try to keep only one and give a shot, not sure I caching creating some issue!
@cnerkar1859 No issues with java 15 and lower, but I have issues using PageFactory.initElements(driver, this); But if I turn to java 17, so getting java.lang.ExceptionInInitializerError in PageFactory.initElements(driver, this); Am I the only one with this issue?
Im getting similar issue and in similar environment:
public BasePage(AppiumDriver appiumDriver){
PageFactory.initElements(new AppiumFieldDecorator(appiumDriver), this);
driver = appiumDriver;
Appium: 2.0.0-beta.44 JavaClient: 8.2.0 java 17.0.4.1 2022-08-18 LTS
error similar to reported above: 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)
is there any solution for this issue everyone? I had the same case
@Hungleminh - I believe we all are in the same boat, for me it's intermittent I am not able to find the root cause yet
one solution is to not use PageFactory at all and just use the old/classic POM as defined in Selenium.dev documentation
one solution is to not use PageFactory at all and just use the old/classic POM as defined in Selenium.dev documentation
I need to use PageFactory to test on cross platform on Android and iOS. Is there any suitable solution to reduce as much as possible code to test on Android and iOS (compare to PageFactory)?