The web browser doesn't show while run selenium test via jenkins
原因:因为jenkins是用windows installer 安装成 windows的服务了,那么jenkins是一个后台服务,所以跑selenium cases 的时候不显示浏览器
解决办法:
Step 1. Control Panel(控制面板) -> Administrative Tools(管理工具) -> Services(服务)
找到Jenkins,右键菜单,执行stop; 右键菜单 “属性” start type 选择“Disabled” 点击 应用,点击确定。(这一步目的:让jenkins不在以windows 服务的方式在后台运行)
Step2. 通过命令行启动Jenkins
java -jar "D:Program Files (x86)Jenkinsjenkins.war"
当然,大家也可以做个bat文件,以后每次启动jenkins,双击运行这个bat文件OK了,bat文件内容如下:
echo "Jenkins CI automation testting"
java -jar "D:Program Files (x86)Jenkinsjenkins.war"
pause
Step3. 重新创建Jenkins的Job,重新配置,在执行测试
问题解决了。
注意问题:
(1)通过这种方式启动jenkins,之前以windows service 启动jenkins的数据都丢失了,需要重新创建job。
(2)之前以windows service 启动jenkins中安装的插件也没有了,需要重新安装所需插件。
其他参考:
If you run Jenkins as a service in the background it won't open apps in the foreground. You may either try to run it not as a service in the foreground, or run it as a Local System account and check Allow the service to interact with desktop option. In the latter case you may get into permission problems, though.