PageFactory.initElements throwing java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;J)V
Description
Trying to get appium to click on my first iOS element in the app. I have set the right desired capabilities since the Appium Desktop is able to open the inspector. But it is throwing -
INFO [IOSAppRegression:55] Step:1 Device: 5s Connecting to Device..........
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;J)V
at io.appium.java_client.pagefactory.TimeOutDuration.setTime(TimeOutDuration.java:54)
at io.appium.java_client.pagefactory.TimeOutDuration.setTime(TimeOutDuration.java:59)
at io.appium.java_client.pagefactory.TimeOutDuration.<init>(TimeOutDuration.java:37)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.<init>(AppiumFieldDecorator.java:80)
at ss.qa.test.IOSAppRegression.prepareTestBed(IOSAppRegression.java:85)
at ss.qa.test.IOSAppRegression.main(IOSAppRegression.java:165)
Environment
- java client build version or git revision if you use some shapshot: 5.0.0-BETA4
- Appium server version or git revision if you use some shapshot: v1.6.4-beta
- Desktop OS/version used to run Appium if necessary: macOS Sierra
- Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: Appium Desktop app
- Mobile platform/version under test: iPhone 5s
- Real device or emulator/simulator: Real device
Details
Gathering all iOS elements on the app to click on.
Code To Reproduce Issue [ Good To Have ]
I have the following set up inside a class -
@iOSFindBy(id = "button_dev") // for iOS native UI
private IOSElement dev_button;
and the following initialization for this page -
PageFactory.initElements(new AppiumFieldDecorator(driver, 15, TimeUnit.SECONDS), introScreen);
@TikhomirovSergey Upgrade to testng 6.11 doesn't seem to help here. @SrinivasanTarget gist is here https://gist.github.com/jaipaddy/323061a7875b1318376a2b3538077d2a
It throws during instantiating IOSDriver; however the app is launched on the iOS device.
We are also running into this with Appium java client 5.0.0-BETA7 selenium-server 3.3.1 selenium-remote-driver 3.3.1 selenium-android-driver 2.39 Appium 1.6.4 TestNG 6.10
Try to update google guava in your pom.xml:
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
with appium server 1.6.6-beta3 + 5.0.0-BETA9, was getting below error at android driver creation step.
Any idea why this weird error message ?
The issue got solved with below entries
**<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>5.0.0-BETA9</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>**
java.lang.NoSuchMethodError: com.google.common.base.Throwables.throwIfUnchecked(Ljava/lang/Throwable;)V
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:176)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:88)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:112)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:73)
at com.serenity.appium.poc.test_classes.AppiumSingleDeviceTest.setup(AppiumSingleDeviceTest.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1191)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
at org.testng.TestNG.run(TestNG.java:1024)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
@vikramvi Its a dependency conflict issue which we are aware of, which is being rectified in latest Selenium version released couple of days back.
It seems we found the rootcause. #714
Getting this issue
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
at org.openqa.selenium.firefox.Preferences.checkPreference(Preferences.java:224)
at org.openqa.selenium.firefox.Preferences.setPreference(Preferences.java:154)
at org.openqa.selenium.firefox.Preferences.setPreference(Preferences.java:125)
at org.openqa.selenium.firefox.Preferences.readDefaultPreferences(Preferences.java:104)
at org.openqa.selenium.firefox.Preferences.
Using below dependencies in pom.xml
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-ie-driver</artifactId>
<version>3.6.0</version>
</dependency>
I'm getting this error:
java.lang.RuntimeException: java.lang.InstantiationException: pages.Pages
at org.openqa.selenium.support.PageFactory.instantiatePage(PageFactory.java:136)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:66)
at steps.PageStore.get(PageStore.java:25)
at steps.AppiumSteps.lambda$new$0(AppiumSteps.java:17)
at ✽.Given mobile able to open browser(D:/Repositories/mobileAutomation/src/test/resources/features/firstAppium.feature:4)
Caused by: java.lang.InstantiationException: pages.Pages
at java.lang.Class.newInstance(Class.java:427)
at org.openqa.selenium.support.PageFactory.instantiatePage(PageFactory.java:133)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:66)
at steps.PageStore.get(PageStore.java:25)
at steps.AppiumSteps.lambda$new$0(AppiumSteps.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at cucumber.runtime.Utils$1.call(Utils.java:40)
at cucumber.runtime.Timeout.timeout(Timeout.java:16)
at cucumber.runtime.Utils.invoke(Utils.java:34)
at cucumber.runtime.java.Java8StepDefinition.execute(Java8StepDefinition.java:115)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:300)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.runtime.Runtime.run(Runtime.java:122)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
Caused by: java.lang.NoSuchMethodException: pages.Pages.
Hi Team, Please help me out i am facing same issue..
java.lang.NoSuchMethodError: com.google.common.base.Throwables.throwIfUnchecked(Ljava/lang/Throwable;)V at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:176)