I am trying to automate with Appium, TestNG and Maven. I am getting errors while initializing the page object model. An error log is attached with this. Tried many ways, but no luck. It would be great if anyone know where I am doing mistakes. java-client --> 6.1.0 testng --> 7.4.0
public final class Driver {
public static void initDriver() {
if (Objects.isNull(DriverManager.getDriver())) {
URL url = null;
try {
url = new URL(“http://127.0.0.1:4723/wd/hub”);
} catch (MalformedURLException e) {
e.printStackTrace();
}
DesiredCapabilities capability = new DesiredCapabilities();
capability.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
capability.setCapability(“appPackage”, AppConstant.appPackage);
capability.setCapability(“appActivity”, AppConstant.appActivity);
AppiumDriver<MobileElement> driver = new AppiumDriver<>(url, capability);
DriverManager.setDriver(driver);
}
}
}
DriverManager for parallel execution:
public final class DriverManager {
private static ThreadLocal<AppiumDriver> driver = new ThreadLocal<AppiumDriver>();
@AndroidFindBy(xpath="//*[@content-desc='Accessibility']")
private MobileElement eleAccessibility;
public HomePage(){
PageFactory.initElements(new AppiumFieldDecorator(DriverManager.getDriver(), Duration.ofSeconds(10)), this);}
public void clickAccessibility() {
eleAccessibility.click();
}
}
Getting below Error:
java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy10.proxyClassLookup()
at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.prepareAnnotationMethods(AppiumByBuilder.java:85)
at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.getFilledValue(AppiumByBuilder.java:92)
at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.createBy(AppiumByBuilder.java:148)
at io.appium.java_client.pagefactory.DefaultElementByBuilder.getBys(DefaultElementByBuilder.java:133)
at io.appium.java_client.pagefactory.DefaultElementByBuilder.buildMobileNativeBy(DefaultElementByBuilder.java:177)
at io.appium.java_client.pagefactory.DefaultElementByBuilder.buildBy(DefaultElementByBuilder.java:216)
at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:66)
at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:53)
at io.appium.java_client.pagefactory.AppiumElementLocatorFactory.createLocator(AppiumElementLocatorFactory.java:1)
at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:56)
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.pages.HomePage.(HomePage.java:23)
at com.testCases.TC001_AccessibilityTest.accessibilityTest(TC001_AccessibilityTest.java:14)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
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.runSequentially(SuiteRunner.java:371)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy10.proxyClassLookup()
at java.base/java.lang.Class.getMethod(Class.java:2195)
at io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.prepareAnnotationMethods(AppiumByBuilder.java:83)
… 42 more
Initially, I started with Java 1.8 in my system, One of your post mentioned to have Java 11. So, yesterday I installed it. Not sure whether I need any extra configuration in Eclipse.
java.lang.NoClassDefFoundError: org/openqa/selenium/logging/LoggingHandler
at com.driver.Driver.initDriver(Driver.java:47)
at com.testCases.BaseTest.invokeAppium(BaseTest.java:22)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
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.SuiteRunner.privateRun(SuiteRunner.java:317)
at org.testng.SuiteRunner.run(SuiteRunner.java:276)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)
at org.testng.TestNG.runSuites(TestNG.java:1063)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.logging.LoggingHandler
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
… 21 more
Hi @Aleksei, start executing by right click on the testng.xml file and running as a suite.
Initially I have not added the selenium dependancy except java-client and it was going at list till the test cases. However now it is not hitting the beforeSuite method itself.
with java-client 7.6.0 I do not use any selenium. i just mentioned it that with 8.0.X version you should user selenium 4.+ if you have it.
so remove from pom.
check in your IDE what Java version it users. e.g. mine in IntelliJ
Thank you very much @Aleksei, I really appreciate for helping me with this problem.
I have installed IntelliJ with the same version which you mentioned and configured the same project and It is working fine. I fill might be some problem with the Eclipse ID version with this configuration.
@Aleksei I’m getting the same error post upgrading to Appium Java client 8.3.0 recently and also upgrading to selenium-server 4.1.2. I’ve my project compiled on JDK11 and my tests run on Saucelabs…Any idea what could be going wrong??