问题
I have created a maven project for Web automation tests I am using code below to launch browser
System.setProperty("webdriver.chrome.driver", "pathChromeDriver");
driver = new ChromeDriver();
driver.manage().window().maximize();
Also I am using Jenkins to execute my test suite and it's working fine.
Now I want to configure browser launch operation from Jenkins without using it in my maven project. Can we do this using plugins available in Jenkins ???
If yes then please help me with that.
回答1:
What you could do is use RemoteWebDriver. From jenkins, make sure there is a machine where the selenium tests can run. On this server you need to run the Selenium Server and chromedriver.
Then from the build plan in jenkins, set the path to the machine, insert the environment variables and have your tests run through remotewebdriver.
Here is some documentation: https://github.com/SeleniumHQ/selenium/wiki/RemoteWebDriver
For Jenkins specific Selenium plugin: https://wiki.jenkins.io/display/JENKINS/Selenium+Plugin
回答2:
If you have installed Jenkins as service then might be chrome is not launch and execution is completed in headless mode. If you want to launch chrome use jenkins .war instead of exe file
来源:https://stackoverflow.com/questions/48278408/how-to-launch-chrome-browser-from-jenkins-directly-instead-of-using-code-in-ecli