Premise: The browser can be started in Myeclipse, but not in Jenkins
Reason : After installing jenkins programmatically, jenkins becomes a service of windows. By default, it is set to automatically start as shown in the figure below. Jenkins is a background service, so the browser is not displayed when running the selenium script.
Solution:
1. Right-click "Computer"->"Management"->"Services and Applications"->"Services", find the service "Jenkins", right-click the properties and change the startup type to "disabled" (this way, Jenkins will not run as a service)
2. Start Jenkins from the command line
java -jar "D:\Jenkins\jenkins.war"
You can also make a bat file, just double-click the bat file. The bat content is as follows:
3. Rebuild a Jenkins project and execute it.