Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2632)

Unified Diff: chrome/test/chromedriver/test/run_py_tests.py

Issue 1827003004: [Chromedriver] Chromedriver should handle unexpected alert automatically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New modifications Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/chromedriver/test/run_py_tests.py
diff --git a/chrome/test/chromedriver/test/run_py_tests.py b/chrome/test/chromedriver/test/run_py_tests.py
index 77a0ec9c8994436b2640070d2cb52be1f7557f20..7467178c4f7469a8c6cdb68205ab1661595cb177 100755
--- a/chrome/test/chromedriver/test/run_py_tests.py
+++ b/chrome/test/chromedriver/test/run_py_tests.py
@@ -202,6 +202,7 @@ _ANDROID_NEGATIVE_FILTER['chromedriver_webview_shell'] = (
'testHistoryNavigationWithPageLoadTimeout',
# Webview shell doesn't support Alerts.
'ChromeDriverTest.testAlert',
+ 'ChromeDesiredCapabilityTest.testUnexpectedAlertBehaviour',
]
)
@@ -1663,6 +1664,19 @@ class ChromeSwitchesCapabilityTest(ChromeDriverBaseTest):
None,
driver.ExecuteScript('return window.domAutomationController'))
samuong 2016/11/02 22:48:48 nit: put two blank lines between classes
gmanikpure 2016/11/04 00:23:24 Done.Also added blank lines for other classes.
+class ChromeDesiredCapabilityTest(ChromeDriverBaseTest):
+ """Tests that chromedriver properly processes desired capabilities."""
+
+ def testUnexpectedAlertBehaviour(self):
+ driver = self.CreateDriver(unexpected_alert_behaviour="accept")
+ self.assertEquals("accept",
+ driver.capabilities['unexpectedAlertBehaviour'])
+ driver.ExecuteScript('alert(\'HI\');')
samuong 2016/11/02 22:48:48 nit: use " and ' instead of escaping the nested '
gmanikpure 2016/11/04 00:23:24 Done.
+ self.WaitForCondition(lambda: driver.IsAlertOpen())
samuong 2016/11/02 22:48:48 no need for a lambda, just do self.WaitForConditio
gmanikpure 2016/11/04 00:23:24 Done, but remvoing lambda throws "TypeError: 'bool
gmanikpure 2016/11/23 18:34:25 I added lambda back.
samuong 2016/11/23 21:28:01 I think you forgot to remove the () after IsAlertO
gmanikpure 2016/11/23 22:04:10 Oops sorry, yes you are right :) Made the change.
+ self.assertRaisesRegexp(chromedriver.UnexpectedAlertOpen,
+ 'unexpected alert open: {Alert text : HI}',
+ driver.FindElement, 'tag name', 'div')
+ self.assertFalse(driver.IsAlertOpen())
class ChromeExtensionsCapabilityTest(ChromeDriverBaseTest):
"""Tests that chromedriver properly processes chromeOptions.extensions."""

Powered by Google App Engine
This is Rietveld 408576698