持续集成 救命!!!jenkins 中自动化测试中遇到无法解决的问题

匿名 · 2020年10月30日 · 最后由 陈恒捷 回复于 2020年11月02日 · 1867 次阅读

# 最近在使用 jenkins 进行自动化测试时遇到了以下几个问题,一直没有办法解决,遂上论坛请教各位前辈:

问题一:jenkins 中 html report 无法正常显示,尝试了网上的以下解决方案均不生效

* 解决方法一:Script 中添加脚本:(重启后不生效)
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "script-src 'unsafe-inline'")

* 解决方法二:修改启动命令(不生效)
java -Dhudson.model.DirectoryBrowserSupport.CSP= -jar jenkins.war

* 解决方法三:(不生效)
tmocat 中 catalina 文件增加 set JAVA_OPTS="-Dhudson.model.DirectoryBrowserSupport.CSP=\"sandbox; default-src 'self';\""

* 解决方法四:(不生效)
job 构建配置中增加 System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","sandbox; default-src 'self';")

页面 F12 报错信息如下:

问题二:自己本地搭建了 jenkis 服务器,使用 master-slave 模式,测试机 nodes 上 jenkins-agent 安装成 windows server,会出现 python 脚本无法启动浏览器问题,jenkins-agent 直接双击运行则没有问题。

报错代码如下:

D:\jenkins_ranlingTest\workspace\Mypipeline\testcase\commonPrepareProject_start.py:45: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
testData = yaml.load(f)
Traceback (most recent call last):
File "E:\soft\softinstall\python3.8.0\lib\unittest\suite.py", line 163, in handleClassSetUp
setUpClass()
File "D:\jenkins_ranlingTest\workspace\Mypipeline\public\models\myunit.py", line 56, in setUpClass
cls.driver = webdriver.Chrome(chrome_options=options,executable_path=chrome_driver)# 解决 pipeline 浏览器驱动报错问题
File "E:\soft\softinstall\python3.8.0\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init
_
RemoteWebDriver.init(
File "E:\soft\softinstall\python3.8.0\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in init
self.start_session(capabilities, browser_profile)
File "E:\soft\softinstall\python3.8.0\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "E:\soft\softinstall\python3.8.0\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "E:\soft\softinstall\python3.8.0\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from timeout: Timed out receiving message from renderer: 600.000
(Session info: chrome=86.0.4240.111)

共收到 4 条回复 时间 点赞

请使用 markdown 排版

问题 1,社区有解决方案,善用搜索:

问题 2,有个地方没看懂,测试机nodes上jenkins-agent安装成windows server,会出现python脚本无法启动浏览器问题,jenkins-agent直接双击运行则没有问题。 ,所以你可以运行和不可以运行,两个场景的区别是什么,可以详细说明下吗?

匿名 #2 · 2020年11月02日
陈恒捷 回复

问题一已经解决。
问题二:1)测试机上 jenkins-agent 安装成 windows server 时,会出现无法找到浏览器驱动 SessionNotCreatedException。
2)测试机上 jenkins-agent 直接以 jar 包运行时一切正常。

建议统一用 jar 包来运行吧。
windows server 和普通进程运行环境差异挺大的,连运行用的用户都不大一样(印象中是统一用 administrator ),所以环境变量啥的也很大可能不一样。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册