summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/old-tests/webdriver/modal
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/old-tests/webdriver/modal
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/old-tests/webdriver/modal')
-rw-r--r--testing/web-platform/tests/old-tests/webdriver/modal/__init__.py0
-rw-r--r--testing/web-platform/tests/old-tests/webdriver/modal/alerts_quit_test.py26
-rw-r--r--testing/web-platform/tests/old-tests/webdriver/modal/alerts_test.py148
-rw-r--r--testing/web-platform/tests/old-tests/webdriver/modal/res/alerts.html53
4 files changed, 227 insertions, 0 deletions
diff --git a/testing/web-platform/tests/old-tests/webdriver/modal/__init__.py b/testing/web-platform/tests/old-tests/webdriver/modal/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/web-platform/tests/old-tests/webdriver/modal/__init__.py
diff --git a/testing/web-platform/tests/old-tests/webdriver/modal/alerts_quit_test.py b/testing/web-platform/tests/old-tests/webdriver/modal/alerts_quit_test.py
new file mode 100644
index 000000000..83f7d1450
--- /dev/null
+++ b/testing/web-platform/tests/old-tests/webdriver/modal/alerts_quit_test.py
@@ -0,0 +1,26 @@
+import os
+import sys
+import unittest
+
+sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
+import base_test
+from selenium.common import exceptions
+from selenium.webdriver.support import wait
+
+
+class AlertsQuitTest(base_test.WebDriverBaseTest):
+ def setUp(self):
+ self.wait = wait.WebDriverWait(self.driver, 5, ignored_exceptions=[exceptions.NoAlertPresentException])
+ self.driver.get(self.webserver.where_is('modal/res/alerts.html'))
+
+ def test_can_quit_when_an_alert_is_present(self):
+ self.driver.find_element_by_css_selector('#alert').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ self.driver.quit()
+ with self.assertRaises(Exception):
+ alert.accept()
+ AlertsQuitTest.driver = None
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/web-platform/tests/old-tests/webdriver/modal/alerts_test.py b/testing/web-platform/tests/old-tests/webdriver/modal/alerts_test.py
new file mode 100644
index 000000000..5f6f8a9f5
--- /dev/null
+++ b/testing/web-platform/tests/old-tests/webdriver/modal/alerts_test.py
@@ -0,0 +1,148 @@
+import os
+import sys
+import unittest
+
+sys.path.insert(1, os.path.abspath(os.path.join(__file__, "../..")))
+import base_test
+from selenium.common import exceptions
+from selenium.webdriver.support import wait
+
+class AlertsTest(base_test.WebDriverBaseTest):
+ def setUp(self):
+ self.wait = wait.WebDriverWait(self.driver, 5, ignored_exceptions = [exceptions.NoAlertPresentException])
+ self.driver.get(self.webserver.where_is('modal/res/alerts.html'))
+
+ def tearDown(self):
+ try:
+ self.driver.switch_to_alert().dismiss()
+ except exceptions.NoAlertPresentException:
+ pass
+
+ # Alerts
+ def test_should_allow_user_to_accept_an_alert(self):
+ self.driver.find_element_by_css_selector('#alert').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.accept()
+ self.driver.current_url
+
+ def test_should_allow_user_to_accept_an_alert_with_no_text(self):
+ self.driver.find_element_by_css_selector('#empty-alert').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.accept()
+ self.driver.current_url
+
+ def test_should_allow_user_to_dismiss_an_alert(self):
+ self.driver.find_element_by_css_selector('#alert').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.dismiss()
+ self.driver.current_url
+
+ def test_should_allow_user_to_get_text_of_an_alert(self):
+ self.driver.find_element_by_css_selector('#alert').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ value = alert.text
+ alert.accept()
+ self.assertEquals('cheese', value)
+
+ def test_setting_the_value_of_an_alert_throws(self):
+ self.driver.find_element_by_css_selector('#alert').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ with self.assertRaises(exceptions.ElementNotVisibleException):
+ alert.send_keys('cheese')
+ alert.accept()
+
+ def test_alert_should_not_allow_additional_commands_if_dismissed(self):
+ self.driver.find_element_by_css_selector('#alert').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.accept()
+ with self.assertRaises(exceptions.NoAlertPresentException):
+ alert.text
+
+ # Prompts
+ def test_should_allow_user_to_accept_a_prompt(self):
+ self.driver.find_element_by_css_selector('#prompt').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.accept()
+ self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == '')
+
+ def test_should_allow_user_to_dismiss_a_prompt(self):
+ self.driver.find_element_by_css_selector('#prompt').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.dismiss()
+ self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'null')
+
+ def test_should_allow_user_to_set_the_value_of_a_prompt(self):
+ self.driver.find_element_by_css_selector('#prompt').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.send_keys('cheese')
+ alert.accept()
+ self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'cheese')
+
+ def test_should_allow_user_to_get_text_of_a_prompt(self):
+ self.driver.find_element_by_css_selector('#prompt').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ value = alert.text
+ alert.accept()
+ self.assertEquals('Enter something', value)
+
+ def test_prompt_should_not_allow_additional_commands_if_dismissed(self):
+ self.driver.find_element_by_css_selector('#prompt').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.accept()
+ with self.assertRaises(exceptions.NoAlertPresentException):
+ alert.text
+
+ def test_prompt_should_use_default_value_if_no_keys_sent(self):
+ self.driver.find_element_by_css_selector('#prompt-with-default').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.accept()
+ self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'This is a default value')
+
+ def test_prompt_should_have_null_value_if_dismissed(self):
+ self.driver.find_element_by_css_selector('#prompt-with-default').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.dismiss()
+ self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'null')
+
+ # Confirmations
+ def test_should_allow_user_to_accept_a_confirm(self):
+ self.driver.find_element_by_css_selector('#confirm').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.accept()
+ self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'true')
+
+ def test_should_allow_user_to_dismiss_a_confirm(self):
+ self.driver.find_element_by_css_selector('#confirm').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.dismiss()
+ self.wait.until(lambda x: x.find_element_by_css_selector('#text').text == 'false')
+
+ def test_setting_the_value_of_a_confirm_throws(self):
+ self.driver.find_element_by_css_selector('#confirm').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ with self.assertRaises(exceptions.ElementNotVisibleException):
+ alert.send_keys('cheese')
+ alert.accept()
+
+ def test_should_allow_user_to_get_text_of_a_confirm(self):
+ self.driver.find_element_by_css_selector('#confirm').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ value = alert.text
+ alert.accept()
+ self.assertEquals('cheese', value)
+
+ def test_confirm_should_not_allow_additional_commands_if_dismissed(self):
+ self.driver.find_element_by_css_selector('#confirm').click()
+ alert = self.wait.until(lambda x: x.switch_to_alert())
+ alert.accept()
+ with self.assertRaises(exceptions.NoAlertPresentException):
+ alert.text
+
+"""
+ def test_switch_to_missing_alert_fails(self):
+ with self.assertRaises(exceptions.NoAlertPresentException):
+ self.driver.switch_to_alert()
+"""
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/web-platform/tests/old-tests/webdriver/modal/res/alerts.html b/testing/web-platform/tests/old-tests/webdriver/modal/res/alerts.html
new file mode 100644
index 000000000..36c5dc139
--- /dev/null
+++ b/testing/web-platform/tests/old-tests/webdriver/modal/res/alerts.html
@@ -0,0 +1,53 @@
+<html>
+<!-- Padding to account for small screens of mobile devices -->
+<style>
+ p {margin-top:48px;}
+</style>
+<head>
+ <title>Testing Alerts</title>
+
+ <script type="text/javascript">
+ function setInnerText(id, value) {
+ document.getElementById(id).innerHTML = '<p>' + value + '</p>';
+ }
+
+ function displayPrompt() {
+ setInnerText('text', prompt('Enter something'));
+ }
+
+ function displayPromptWithDefault() {
+ setInnerText('text', prompt('Enter something', 'This is a default value'));
+ }
+
+ function displayTwoPrompts() {
+ setInnerText('text1', prompt('First'));
+ setInnerText('text2', prompt('Second'));
+ }
+
+ function displayConfirm() {
+ setInnerText('text', confirm('cheese'));
+ }
+ </script>
+</head>
+<body>
+
+<h1>Testing Alerts and Stuff</h1>
+
+<p>This tests alerts: <a href="#" id="alert" onclick="alert('cheese');">click me</a></p>
+
+<p>This tests alerts: <a href="#" id="empty-alert" onclick="alert('');">click me</a></p>
+
+<p>Let's make the <a href="#" id="prompt" onclick="displayPrompt();">prompt happen</a></p>
+
+<p>Let's make the <a href="#" id="prompt-with-default" onclick="displayPromptWithDefault();">prompt with default happen</a></p>
+
+<p>Let's make TWO <a href="#" id="double-prompt" onclick="displayTwoPrompts();">prompts happen</a></p>
+
+<p>This tests confirm: <a href="#" id="confirm" onclick="displayConfirm();">test confirm</a></p>
+
+<div id="text"></div>
+<div id="text1"></div>
+<div id="text2"></div>
+
+</body>
+</html>