java-client icon indicating copy to clipboard operation
java-client copied to clipboard

ExceptionI while trying to Initialise Page factory with Java client 6.0.0

Open Siddh010 opened this issue 8 years ago • 13 comments

Description

While trying to initialise Page factory using below code we are getting java.lang.ExceptionInInitializerError exception

PageFactory.initElements(new AppiumFieldDecorator(driver), this);

Environment

  • java client build version or git revision if you use some shapshot: 6.0.0
  • Appium server version or git revision if you use some shapshot:1.8.1
  • Desktop OS/version used to run Appium if necessary: 1.6.2
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe:
  • Mobile platform/version under test: iOS 11.0.1
  • Real device or emulator/simulator: real device

Details

With Java client 5.0.0 it is working fine.

Code To Reproduce Issue [ Good To Have ]

PageFactory.initElements(new AppiumFieldDecorator(driver), this);

Ecxeption stacktraces

Please create a gist with pasted stacktrace of exception thrown by java.

java.lang.ExceptionInInitializerError at io.appium.java_client.pagefactory.utils.ProxyFactory.getEnhancedProxy(ProxyFactory.java:52) at io.appium.java_client.pagefactory.utils.ProxyFactory.getEnhancedProxy(ProxyFactory.java:33) at io.appium.java_client.pagefactory.AppiumFieldDecorator.proxyForAnElement(AppiumFieldDecorator.java:217) at io.appium.java_client.pagefactory.AppiumFieldDecorator.access$0(AppiumFieldDecorator.java:215) at io.appium.java_client.pagefactory.AppiumFieldDecorator$1.proxyForLocator(AppiumFieldDecorator.java:107) at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:62) at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:155) at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:113) at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:105) at com.greatWest.pageObject.LoginPage.(LoginPage.java:82)

Link to Appium logs

Siddh010 avatar Jun 19 '18 08:06 Siddh010

Remove maven dependency for selenium WebDriver and started working. Internally Java-client now call selenium webdriver..

Siddh010 avatar Jun 26 '18 09:06 Siddh010

@Sidd' But I am not using Selenium WebDriver as dependancy :(

narendra-chandratre avatar Aug 07 '18 09:08 narendra-chandratre

@Siddh010 Even I am facing the same issue. Have implemented page factory model in the project but exception occurs the moment my class get initialized.

I have updated the selenium-server, selenium-java to Version 3.13 and my appium java-client to Version 6.1.0. Appium 1.8.1 is being used.

Any help would be appreciated.

kapilsuri87 avatar Sep 18 '18 05:09 kapilsuri87

@narendra-chandratre @kapilsuri87 check if you're using cucumber (cukes). I solved it by removing that dependency

jpita avatar Sep 19 '18 08:09 jpita

@jpita : Please confirm if you want me to update all cucumber dependencies from "info.cukes" to "io.cucumber" dependencies??

kapilsuri87 avatar Sep 19 '18 09:09 kapilsuri87

I just deleted them, I don't need them

jpita avatar Sep 19 '18 09:09 jpita

But I have implemented cucumber as a BDD framework. Can not really delete the same.

Also, not sure what dependencies are going to resolve by deleting the cucumber maven dependencies.

kapilsuri87 avatar Sep 19 '18 11:09 kapilsuri87

is there any resolution to this issue? Please reply.

madhusmitanishu avatar May 10 '20 06:05 madhusmitanishu

The only way I could resolve the issue was to use webElement and not mobileElement.

kapilsuri87 avatar May 10 '20 07:05 kapilsuri87

set your android driver like this 'private AndroidDriver < WebElement > driver = null;' and degrade java-client to 7.4.1. your issue will be resolved.

Kajugul avatar Jun 06 '21 05:06 Kajugul

For me @Siddh010 Solution worked. Thanks heaps mate

Manasaanand avatar Oct 25 '21 06:10 Manasaanand

Hi, Am Still facing the same issue.

Dependencies:

  1. Java-client am using 7.4.1
  2. TestNg: 7.4.0

Declared driver as "public AndroidDriver mDriver = null;"

In Page class: public class LoginPage extends MobileBase { public LoginPage() { PageFactory.initElements(new AppiumFieldDecorator(mDriver), this); }

But no luck. Could some one provide workable solution.

Kishorekumar2789 avatar Jan 26 '22 13:01 Kishorekumar2789

hi guys please help me . i'm getting this exception i'm using java client 8.2.0 java.lang.ExceptionInInitializerError at io.appium.java_client.pagefactory.utils.ProxyFactory.getEnhancedProxy(ProxyFactory.java:52) at io.appium.java_client.pagefactory.utils.ProxyFactory.getEnhancedProxy(ProxyFactory.java:33) at io.appium.java_client.pagefactory.AppiumFieldDecorator.proxyForAnElement(AppiumFieldDecorator.java:217) at io.appium.java_client.pagefactory.AppiumFieldDecorator.access$0(AppiumFieldDecorator.java:215) at io.appium.java_client.pagefactory.AppiumFieldDecorator$1.proxyForLocator(AppiumFieldDecorator.java:107) at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:62) at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:155) at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:113) at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:105) at com.greatWest.pageObject.LoginPage.(LoginPage.java:82)

Demudu1995 avatar Oct 27 '22 10:10 Demudu1995