添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The problem

There are no any exceptions for the following commands: alertAccept , alertDismiss , alertText .

exports.config = {
	mochaOpts: { timeout: 60 * (60 * 1000) },
browser.url('https://mail.ru');
browser.alertAccept();

This test will be finished in an hour. At least, this situation looks like a big problem for me and other people who don't know about that.

In accordance with the WebDriver protocol these errors should be handled

Error Code HTTP Status JSON Error Code Description

The log

22:29:05.461 INFO - Executing: [accept alert])
22:29:11.169 WARN - Exception: timeout: cannot determine loading status
from timeout: Timed out receiving message from renderer: -0.006
  (Session info: chrome=55.0.2883.95)
  (Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.2 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15.01 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'aabashkin.local', ip: '192.168.1.43', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1), userDataDir=/var/folders/0y/jg1cdcj50zv2vjsjzxtsfhqc0000gp/T/.org.chromium.Chromium.3zPsVA}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=55.0.2883.95, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 0738fc721d08a63faacedcddc28ee06e
22:29:31.186 WARN - Exception thrown
org.openqa.selenium.NoAlertPresentException: no alert open
  (Session info: chrome=55.0.2883.95)
  (Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.2 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 4 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'aabashkin.local', ip: '192.168.1.43', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1), userDataDir=/var/folders/0y/jg1cdcj50zv2vjsjzxtsfhqc0000gp/T/.org.chromium.Chromium.3zPsVA}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=55.0.2883.95, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 0738fc721d08a63faacedcddc28ee06e
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701)
	at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.alert(RemoteWebDriver.java:1049)
	at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringTargetLocator.alert(EventFiringWebDriver.java:615)
	at org.openqa.selenium.remote.server.handler.AcceptAlert.call(AcceptAlert.java:28)
	at org.openqa.selenium.remote.server.handler.AcceptAlert.call(AcceptAlert.java:1)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
22:29:35.464 INFO - Executing: [accept alert])
22:30:05.472 INFO - Executing: [accept alert])
22:30:26.233 WARN - Exception: no alert open
  (Session info: chrome=55.0.2883.95)
  (Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.2 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 4 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'aabashkin.local', ip: '192.168.1.43', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1), userDataDir=/var/folders/0y/jg1cdcj50zv2vjsjzxtsfhqc0000gp/T/.org.chromium.Chromium.3zPsVA}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=55.0.2883.95, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 0738fc721d08a63faacedcddc28ee06e

1788.zip

I found a temporary solution to solve my problem:

let hasAlert = function () {
	try {
		browser.getTitle();
	catch (error) {
		return error.seleniumStack.type === 'UnexpectedAlertOpen';
	return false;
          

I just tested this against master, and it seems that 8b12008 has fixed this issue.

I tested all three functions (alertDismiss, alertAccept, alertText) on pages with alerts and pages without alerts. alertText (the problem function) was tested for both the jsonwire happy path (/session/:sessionId/alert_text), and the webdriver fallback path.

The current behaviour on master for all three functions (as mentioned in the previous paragraph): throw an exception with the exception.type of RuntimeError, and the exception.seleniumStack.type of NoAlertOpenError.

Based on that, I would say this could be closed... unless throwing errors is not expected behaviour. If it is expected behaviour @christian-bromann, comment so and I can add something to the docs around an exception being thrown if no alert was present.