File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
java/client/test/org/openqa/selenium Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -597,6 +597,24 @@ public void testCanQuitWhenAnAlertIsPresent() {
597597 driver .quit ();
598598 }
599599
600+ @ JavascriptEnabled
601+ @ Test
602+ @ Ignore (value = MARIONETTE , issue = "https://github.com/mozilla/geckodriver/issues/620" )
603+ public void shouldHandleAlertOnFormSubmit () {
604+ driver .get (appServer .create (new Page ().withTitle ("Testing Alerts" ).withBody (
605+ "<form id='theForm' action='javascript:alert(\" Tasty cheese\" );'>" ,
606+ "<input id='unused' type='submit' value='Submit'>" ,
607+ "</form>" )));
608+
609+ driver .findElement (By .id ("theForm" )).submit ();
610+ Alert alert = wait .until (alertIsPresent ());
611+ String value = alert .getText ();
612+ alert .accept ();
613+
614+ assertEquals ("Tasty cheese" , value );
615+ assertEquals ("Testing Alerts" , driver .getTitle ());
616+ }
617+
600618 private static ExpectedCondition <Boolean > textInElementLocated (
601619 final By locator , final String text ) {
602620 return driver -> text .equals (driver .findElement (locator ).getText ());
Original file line number Diff line number Diff line change 2525import static org .junit .Assert .assertThat ;
2626import static org .junit .Assert .assertTrue ;
2727import static org .junit .Assume .assumeFalse ;
28+ import static org .openqa .selenium .support .ui .ExpectedConditions .alertIsPresent ;
2829import static org .openqa .selenium .support .ui .ExpectedConditions .titleIs ;
2930import static org .openqa .selenium .testing .Driver .IE ;
3031import static org .openqa .selenium .testing .Driver .MARIONETTE ;
@@ -272,12 +273,13 @@ public void testEmptyTextBoxesShouldReturnAnEmptyStringNotNull() {
272273 @ Test
273274 @ Ignore (PHANTOMJS )
274275 @ Ignore (SAFARI )
276+ @ Ignore (value = MARIONETTE , issue = "https://github.com/mozilla/geckodriver/issues/620" )
275277 public void handleFormWithJavascriptAction () {
276278 String url = appServer .whereIs ("form_handling_js_submit.html" );
277279 driver .get (url );
278280 WebElement element = driver .findElement (By .id ("theForm" ));
279281 element .submit ();
280- Alert alert = driver . switchTo (). alert ( );
282+ Alert alert = wait . until ( alertIsPresent () );
281283 String text = alert .getText ();
282284 alert .accept ();
283285
You can’t perform that action at this time.
0 commit comments