webdrivermanager icon indicating copy to clipboard operation
webdrivermanager copied to clipboard

Getting a java.lang.NullPointerException when I use containerized browsers [Verified for Chrome, Safari, Firefox]

Open sajithatharaka opened this issue 5 years ago • 3 comments

Description of the problem: I am getting a null pointer exception when I try to run the browser using docker. However, this worked on last weekend. image

Operating system: Windows 10

WebDriverManager version: 5.0.1

WebDriverManager call:

WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker()
        .enableVnc().enableRecording();

@BeforeTest
void setupTest() {
    driver = wdm.create();
}

@AfterTest
void teardown() {
    wdm.quit();
}

@org.testng.annotations.Test
void test() {
    driver.get("https://github.com/bonigarcia/webdrivermanager");
}

Error log: WebDriverManager traces: java.lang.NullPointerException at web.browser.Safari.test(Safari.java:36) 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:134) at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:597) 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:816) 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.util.ArrayList.forEach(ArrayList.java:1259) at org.testng.TestRunner.privateRun(TestRunner.java:766) at org.testng.TestRunner.run(TestRunner.java:587) at org.testng.SuiteRunner.runTest(SuiteRunner.java:384) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337) at org.testng.SuiteRunner.run(SuiteRunner.java:286) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187) at org.testng.TestNG.runSuitesLocally(TestNG.java:1109) at org.testng.TestNG.runSuites(TestNG.java:1039) at org.testng.TestNG.run(TestNG.java:1007) at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66) at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)

sajithatharaka avatar Sep 16 '21 12:09 sajithatharaka

As per my understanding, this is basically the driver has not been initialized. I did a factory reset to the Docker and ran the tests. Seems like it is not trying to fetch the docker images.

sajithatharaka avatar Sep 16 '21 12:09 sajithatharaka

It seems your setupTest method is not being executed. In any case, you are not reporting the WebDriverManager traces (the error trace is a different thing). Without that information, I am unable to trace any possible problem. Moreover, it seems your are not using the latest version of WebDriverManager. I'm closing this issue now. It the problem persists in the latest version, please open a new issue an report all the required information in the issue template.

bonigarcia avatar Sep 17 '21 15:09 bonigarcia

Thanks @bonigarcia

This was due to a conflict in dependencies used in webdrivermanager and other libraries. After an investigation, I found there are common libraries used by both cucumber-reporting and webdrivermanager.

Guava library was the common library used. I upgraded the cucumber-reporting version from 3.8.0 to 5.4.0 and then the issue was resolved.

Anyone encountered this issue - most of the time this may be due to conflicts in libraries.

sajithatharaka avatar Sep 27 '21 07:09 sajithatharaka