I have the below code in selenium/java test class. Now this code i have pushed to github. Also, I have setup the jenkins job to execute the same code (in the jenkins job i have pointed the code to github). The jenkins job is triggering fine and started executing the test, but throwing below error while opening browser. The test case is supposed to open firefox browser, but the firefox browing is not opening.
So, my question is, whether the below selenium code is correct if i want to execute the test case in Jenkins job (jenkins server is running in Cento7.4 OS).
NOTE: In the same CentOS VM, i am able to execute the same (below) selenium code in eclipse and its able to open the firefox browser and open the url without any issues. The issue is coming only if i try to run the same code in Jenkins server as a jenkins job.
Selenium code:
System.setProperty("webdriver.gecko.driver", "geckodriver");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.addArguments("--display=0");
WebDriver driver = new FirefoxDriver(firefoxOptions);
driver.get("https://www.facebook.com");
Jenkins job output:
Running TestSuite
Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
1597912923234 mozrunner::runner INFO Running command: "/bin/firefox" "-marionette" "--display=0" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileFz0Zr2"
Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Running without a11y support!
Error: cannot open display: 0
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.972 sec <<< FAILURE!
Results :
Failed tests: loginTest4(com.training.browsers.LinuxTest): invalid argument: can't kill an exited process
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[ERROR] There are test failures.
xauth list output below:
[root@localhost ~]# xauth list
localhost.localdomain/unix:0 MIT-MAGIC-COOKIE-1 4eb74af687f2dbc022ef03617614456e
#ffff#6c6f63616c686f73742e6c6f63616c646f6d61696e#:0 MIT-MAGIC-COOKIE-1 4eb74af687f2dbc022ef03617614456e
Aucun commentaire:
Enregistrer un commentaire