Handle alerts #1788

Open
monolithed opened this Issue Dec 22, 2016 · 1 comment

Projects

None yet

2 participants

@monolithed
Contributor
monolithed commented Dec 22, 2016 edited

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
no such alert 400 no such alert An attempt was made to operate on a modal dialog when one was not open

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

@monolithed monolithed changed the title from Add isAlertPresent to Handle alert Dec 22, 2016
@monolithed monolithed changed the title from Handle alert to Handle alerts Dec 22, 2016
@monolithed
Contributor
monolithed commented Dec 27, 2016 edited

I found a temporary solution to solve my problem:

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

	return false;
}
@christian-bromann christian-bromann self-assigned this Jan 17, 2017
@christian-bromann christian-bromann added this to the Upcoming milestone Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment