I have set up a test automation project using Selenium and Java, along with the TestNG framework. For managing the project and building, I am using Maven. The tests run perfectly fine when executed locally using Maven commands. However, I've encountered an issue when attempting to run the same tests via Jenkins
Error:
Exception in thread "TestNG-test= Master Runner -5" java.lang.IllegalArgumentException: Input must be set
at org.openqa.selenium.internal.Require.nonNull(Require.java:60)
at org.openqa.selenium.support.ui.FluentWait.<init>(FluentWait.java:94)
at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:74)
at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:43)
at co......qa.pages.base.BasePage.<init>(BasePage.java:69)
at co......qa.listeners.ListenerClass.onTestFailure(ListenerClass.java:109)
at org.testng.internal.TestListenerHelper.runTestListeners(TestListenerHelper.java:99)
at org.testng.internal.invokers.TestInvoker.runTestResultListener(TestInvoker.java:277)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:985)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Browser Version : Chrome - 115.0.5790.110 , Firefox - 116.0.2 , Jenkins 2.401.3
Local Testing: I ran the tests locally using Maven commands and confirmed their successful execution. This indicated that the scripts and WebDriver instantiation were correct and functional.
WebDriver Compatibility: I ensured that the WebDriver version aligned with the browser version I was using. This was to prevent any compatibility problems that might arise from mismatched versions.
WebDriver Manager: I incorporated the WebDriver Manager to handle WebDriver binaries and versions automatically. This was intended to maintain consistent WebDriver versioning across different environments.
Despite these efforts, I encountered a persistent problem: the WebDriver instance remained null when executing tests via Jenkins. Consequently, all test scripts failed to run. I'm seeking assistance to understand the underlying cause of the null instance issue and any potential solutions to address it.
please check the below one by one. it's hard to understand from the questions, but the following checks should point you towards the issue
WebDriver Initialization: Ensure that the WebDriver instance is correctly initialized and is not null when the tests are run via Jenkins.
Environment Differences: There might be differences between your local environment and the Jenkins environment. Ensure that all dependencies, configurations, and paths are correctly set up in Jenkins.
Jenkins Configuration: Ensure that Jenkins has the necessary permissions and configurations to access and run the Selenium WebDriver.