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

PageFactory.initElements throwing java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;J)V

Open jaipaddy opened this issue 9 years ago • 29 comments

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);

jaipaddy avatar Mar 04 '17 17:03 jaipaddy

@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.

jaipaddy avatar Mar 29 '17 16:03 jaipaddy

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

aaronmagi avatar Apr 19 '17 18:04 aaronmagi

Try to update google guava in your pom.xml:

<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>

mykola-mokhnach avatar Apr 19 '17 18:04 mykola-mokhnach

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 avatar Jul 26 '17 10:07 vikramvi

@vikramvi Its a dependency conflict issue which we are aware of, which is being rectified in latest Selenium version released couple of days back.

SrinivasanTarget avatar Jul 26 '17 16:07 SrinivasanTarget

It seems we found the rootcause. #714

TikhomirovSergey avatar Aug 31 '17 09:08 TikhomirovSergey

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.(Preferences.java:65) at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:81) at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:71) at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:60) at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:139) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:98) at com.snapdeal.payments.qe.checkout.configuration.DriverFactory.setDriver(DriverFactory.java:185) at com.snapdeal.payments.qe.checkout.configuration.DriverFactory.setDriver(DriverFactory.java:174) at com.snapdeal.payments.qe.checkout.utils.TestBase.beforeTest(TestBase.java:437) 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:552) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215) at org.testng.internal.Invoker.invokeMethod(Invoker.java:636) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:882) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1189) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:348) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305) at org.testng.SuiteRunner.run(SuiteRunner.java:254) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) at org.testng.TestNG.run(TestNG.java:1057) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

Using below dependencies in pom.xml org.seleniumhq.selenium selenium-chrome-driver 3.6.0

	<dependency>
		<groupId>org.seleniumhq.selenium</groupId>
		<artifactId>selenium-ie-driver</artifactId>
		<version>3.6.0</version>
	</dependency>
org.seleniumhq.selenium selenium-java 3.6.0 org.seleniumhq.selenium selenium-firefox-driver 3.6.0 org.seleniumhq.selenium selenium-api 3.6.0 org.seleniumhq.selenium selenium-server 3.6.0 javax.servlet servlet-api com.google.guava guava 21.0 org.seleniumhq.selenium htmlunit-driver 2.27 org.testng testng 6.11 test

ritesh2689 avatar Oct 16 '17 08:10 ritesh2689

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.() at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.newInstance(Class.java:412) ... 21 more

sudoManju avatar Mar 11 '18 06:03 sudoManju

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)

Shrikant2612 avatar Jun 06 '18 13:06 Shrikant2612