我有: Jenkins,Selenium Server Standalone 3.11.0,Chrome 65.0.3325.146和Chromedriver 2.36.540471。
问题:由于我的一天测试开始在Jenkins上失败并出现以下错误:“WebDriverError:未知错误:未知会话” - 本地工作没有任何问题。
以下是Jenkins的控制台输出:
[11:15:41] I/start - java -Djava.security.egd=file:///dev/./urandom -Dwebdriver.chrome.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.36 -Dwebdriver.gecko.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.20.0 -jar /usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.11.0.jar -port 4474
[11:15:41] I/start - seleniumProcess.pid: 9625
11:15:41.964 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.11.0', revision: 'e59cfb3'
11:15:41.966 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4474
2018-03-13 11:15:42.112:INFO::main: Logging initialized @571ms to org.seleniumhq.jetty9.util.log.StdErrLog
11:15:42.411 INFO [SeleniumServer.boot] - Welcome to Selenium for Workgroups....
11:15:42.411 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4474
...
[11:15:46] I/launcher - Running 1 instances of WebDriver
[11:15:46] I/hosted - Using the selenium server at http://localhost:4474/wd/hub
11:15:46.712 INFO [ActiveSessionFactory.apply] - Capabilities are: Capabilities {browserName: chrome, chromeOptions: {args: [--headless, --disable-extensions, --disable-gpu, --no-sandbox, --disable-default-apps, --window-size=1600,1000]}, count: 1, version: ANY}
11:15:46.714 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752) on port 5633
Only local connections are allowed.
11:15:47.492 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
11:15:47.976 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session c69cbc9da3e084a1e6f43d74b8532431 (org.openqa.selenium.chrome.ChromeDriverService)
Started
[1520936158.443][SEVERE]: Unable to retrieve document state unknown error: unknown sessionId
[31mF [0m
Failures:
1) test for timeline should add new profile
Message:
[31m Failed: unknown error: unknown sessionId
(Session info: headless chrome=65.0.3325.146)
(Driver info: chromedriver=2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752),platform=Linux 3.19.0-64-generic x86_64) [0m
Stack:
WebDriverError: unknown error: unknown sessionId
(Session info: headless chrome=65.0.3325.146)
(Driver info: chromedriver=2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752),platform=Linux 3.19.0-64-generic x86_64)
at Object.checkLegacyResponse (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/error.js:505:15)
at parseHttpResponse (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/http.js:440:13)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.findElements(By(css selector, input.text-input.text-input-md))
at thenableWebDriverProxy.schedule (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/webdriver.js:816:17)
at thenableWebDriverProxy.findElements (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/webdriver.js:1057:22)
at ptor.waitForAngular.then (/var/lib/jenkins/jobs/run all/workspace/node_modules/protractor/lib/element.ts:166:36)
at ManagedPromise.invokeCallback_ (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/promise.js:1366:14)
at TaskQueue.execute_ (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/promise.js:2970:14)
at TaskQueue.executeNext_ (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/promise.js:2953:27)
at asyncRun (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/promise.js:2813:27)
at /var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/promise.js:676:7
at <anonymous>Error
at ElementArrayFinder.applyAction_ (/var/lib/jenkins/jobs/run all/workspace/node_modules/protractor/lib/element.ts:482:23)
at ElementArrayFinder.(anonymous function).args [as sendKeys] (/var/lib/jenkins/jobs/run all/workspace/node_modules/protractor/lib/element.ts:96:21)
at ElementFinder.(anonymous function).args [as sendKeys] (/var/lib/jenkins/jobs/run all/workspace/node_modules/protractor/lib/element.ts:873:14)
at WebAppProfile.setProfile (/var/lib/jenkins/jobs/run all/workspace/tmp/page/web-app/profile-web-app.js:51:23)
at /var/lib/jenkins/jobs/run all/workspace/tmp/test/profile/user-activity.js:26:43
at ManagedPromise.invokeCallback_ (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/promise.js:1366:14)
at TaskQueue.execute_ (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/promise.js:2970:14)
at TaskQueue.executeNext_ (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/promise.js:2953:27)
at asyncRun (/var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/promise.js:2813:27)
at /var/lib/jenkins/jobs/run all/workspace/node_modules/selenium-webdriver/lib/promise.js:676:7
From: Task: Run it("should add new profile") in control flow
at UserContext.<anonymous> (/var/lib/jenkins/jobs/run all/workspace/node_modules/jasminewd2/index.js:94:19)
From asynchronous test:
Error
at Suite.<anonymous> (/var/lib/jenkins/jobs/run all/workspace/tmp/test/profile/user-activity.js:16:5)
at Object.<anonymous> (/var/lib/jenkins/jobs/run all/workspace/tmp/test/profile/user-activity.js:15:1)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
1 spec, 1 failure
Finished in 10.703 seconds
11:15:58.841 INFO [ActiveSessions$1.onStop] - Removing session c69cbc9da3e084a1e6f43d74b8532431 (org.openqa.selenium.chrome.ChromeDriverService)
[11:15:58] I/launcher - 0 instance(s) of WebDriver still running
[11:15:58] I/launcher - chromeANY #01 failed 1 test(s)
[11:15:58] I/launcher - overall: 1 failed spec(s)
Closing report
[11:15:58] E/launcher - Process exited with error code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app-e2e-tests@1.0.0 user-activity: `protractor tmp/specs/profile/user-activity-spec.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app-e2e-tests@1.0.0 user-activity script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /var/lib/jenkins/.npm/_logs/2018-03-13T10_15_58_855Z-debug.log
Process leaked file descriptors. See https://jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors for more information
Build step 'Execute shell' marked build as failure
Recording test results
Finished: FAILURE
在这个测试中,我试图访问网站(它是一个PWA)并通过表单发送一些数据 - 根据截图测试在表单模态打开时挂起。令我感到非常困惑的是,我在其他测试中使用相同的方法进行数据发送,这些测试正在通过......
解决方案:本地Chrome更新(至第65版)让我可以查看有问题的测试期间发生了什么 - 推送通知弹出正在中断表单填写。我在配置中将其关闭并再次进行测试。