我们最近在我们的Protractor测试中转而使用无头Chrome。除了在测试系统模态时,一切都很好。想知道这是否支持运行Chrome无头?并且,如果是这样,希望有人能够了解为什么我们的测试超时等待系统模态出现。 TIA!
的Xvfb
Xvfb :0 -screen 0 800x600x16
xvfb-run node_modules/.bin/webdriver-manager start
量角器配置
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
baseUrl: 'http://localhost/cdash/',
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--headless", "--disable-gpu", "--window-size=800x600" ]
}
}
}
量角器测试1
...
// This generates a confirmation dialog which we have to accept.
// Wait for it to appear.
browser.wait(protractor.ExpectedConditions.alertIsPresent(), 10000);
// Then switch to it & click on it.
browser.switchTo().alert().accept();
...
Selenium异常输出
08:49:19.709 INFO - Executing: [get alert text])
08:49:19.711 WARN - Exception thrown
org.openqa.selenium.NoAlertPresentException: no alert open
(Session info: headless chrome=59.0.3071.115)
(Driver info: chromedriver=2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262),platform=Mac OS X 10.12.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2 milliseconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'bryons-mbp.domain.tld', ip: 'x.x.x.x', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262), userDataDir=/var/folders/tq/b216ws_s64x2g2dgm3_gf4340000gn/T/.org.chromium.Chromium.2uF8Pp}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=59.0.3071.115, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
量角器输出(通过ctest)
116: 1) manageBuildGroup can delete buildgroups
116: Message:
116: Error: Wait timed out after 1008ms
116: Stacktrace:
116: Error: Wait timed out after 1008ms
116: at Array.forEach (native)
116: at process._tickCallback (internal/process/next_tick.js:103:7)