救命!!!jenkins 中自動化測試中遇到無法解決的問題

ranling908發表於2020-10-30

最近在使用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)

相關文章