Skip to content

Commit 7fa30c0

Browse files
committed
Gadgets/Stdrev: Convert Selenium IDE tests to Webdriver
1 parent e8e2e2d commit 7fa30c0

25 files changed

Lines changed: 962 additions & 1313 deletions

gadgets/standard_revisions-tests/hides-dcl-items-in-dcl-rev.html

Lines changed: 0 additions & 77 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# -*- coding: utf-8 -*-
2+
from selenium import webdriver
3+
from selenium.webdriver.common.by import By
4+
from selenium.webdriver.common.keys import Keys
5+
from selenium.webdriver.support.ui import Select
6+
from selenium.common.exceptions import NoSuchElementException
7+
from selenium.common.exceptions import NoAlertPresentException
8+
import unittest, time, re
9+
10+
class HidesDclItemsInDclRev(unittest.TestCase):
11+
def setUp(self):
12+
self.driver = webdriver.Firefox()
13+
self.driver.implicitly_wait(30)
14+
self.base_url = "http://en.cppreference.com/"
15+
self.verificationErrors = []
16+
self.accept_next_alert = True
17+
18+
def test_hides_dcl_items_in_dcl_rev(self):
19+
driver = self.driver
20+
driver.get(self.base_url + "/w/test-gadget-stdrev/hides-dcl-items-in-dcl-rev")
21+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void always_visible[\s\S]*$")
22+
except AssertionError as e: self.verificationErrors.append(str(e))
23+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx98[\s\S]*$")
24+
except AssertionError as e: self.verificationErrors.append(str(e))
25+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx11[\s\S]*$")
26+
except AssertionError as e: self.verificationErrors.append(str(e))
27+
Select(driver.find_element_by_css_selector("select")).select_by_visible_text("C++98/03")
28+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void always_visible[\s\S]*$")
29+
except AssertionError as e: self.verificationErrors.append(str(e))
30+
try: self.assertNotRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx98[\s\S]*$")
31+
except AssertionError as e: self.verificationErrors.append(str(e))
32+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx11[\s\S]*$")
33+
except AssertionError as e: self.verificationErrors.append(str(e))
34+
Select(driver.find_element_by_css_selector("select")).select_by_visible_text("C++11")
35+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void always_visible[\s\S]*$")
36+
except AssertionError as e: self.verificationErrors.append(str(e))
37+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx98[\s\S]*$")
38+
except AssertionError as e: self.verificationErrors.append(str(e))
39+
try: self.assertNotRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx11[\s\S]*$")
40+
except AssertionError as e: self.verificationErrors.append(str(e))
41+
42+
def is_element_present(self, how, what):
43+
try: self.driver.find_element(by=how, value=what)
44+
except NoSuchElementException as e: return False
45+
return True
46+
47+
def is_alert_present(self):
48+
try: self.driver.switch_to_alert()
49+
except NoAlertPresentException as e: return False
50+
return True
51+
52+
def close_alert_and_get_its_text(self):
53+
try:
54+
alert = self.driver.switch_to_alert()
55+
alert_text = alert.text
56+
if self.accept_next_alert:
57+
alert.accept()
58+
else:
59+
alert.dismiss()
60+
return alert_text
61+
finally: self.accept_next_alert = True
62+
63+
def tearDown(self):
64+
self.driver.quit()
65+
self.assertEqual([], self.verificationErrors)
66+
67+
if __name__ == "__main__":
68+
unittest.main()

gadgets/standard_revisions-tests/hides-dcl-items-in-member.html

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# -*- coding: utf-8 -*-
2+
from selenium import webdriver
3+
from selenium.webdriver.common.by import By
4+
from selenium.webdriver.common.keys import Keys
5+
from selenium.webdriver.support.ui import Select
6+
from selenium.common.exceptions import NoSuchElementException
7+
from selenium.common.exceptions import NoAlertPresentException
8+
import unittest, time, re
9+
10+
class HidesDclItemsInMember(unittest.TestCase):
11+
def setUp(self):
12+
self.driver = webdriver.Firefox()
13+
self.driver.implicitly_wait(30)
14+
self.base_url = "http://en.cppreference.com/"
15+
self.verificationErrors = []
16+
self.accept_next_alert = True
17+
18+
def test_hides_dcl_items_in_member(self):
19+
driver = self.driver
20+
driver.get(self.base_url + "/w/test-gadget-stdrev/hides-dcl-items-in-member")
21+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void always_visible[\s\S]*$")
22+
except AssertionError as e: self.verificationErrors.append(str(e))
23+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx98[\s\S]*$")
24+
except AssertionError as e: self.verificationErrors.append(str(e))
25+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx11[\s\S]*$")
26+
except AssertionError as e: self.verificationErrors.append(str(e))
27+
Select(driver.find_element_by_css_selector("select")).select_by_visible_text("C++98/03")
28+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void always_visible[\s\S]*$")
29+
except AssertionError as e: self.verificationErrors.append(str(e))
30+
try: self.assertNotRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx98[\s\S]*$")
31+
except AssertionError as e: self.verificationErrors.append(str(e))
32+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx11[\s\S]*$")
33+
except AssertionError as e: self.verificationErrors.append(str(e))
34+
Select(driver.find_element_by_css_selector("select")).select_by_visible_text("C++11")
35+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void always_visible[\s\S]*$")
36+
except AssertionError as e: self.verificationErrors.append(str(e))
37+
try: self.assertRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx98[\s\S]*$")
38+
except AssertionError as e: self.verificationErrors.append(str(e))
39+
try: self.assertNotRegexpMatches(driver.find_element_by_xpath("//body").text, r"^[\s\S]*void not_visible_in_cxx11[\s\S]*$")
40+
except AssertionError as e: self.verificationErrors.append(str(e))
41+
42+
def is_element_present(self, how, what):
43+
try: self.driver.find_element(by=how, value=what)
44+
except NoSuchElementException as e: return False
45+
return True
46+
47+
def is_alert_present(self):
48+
try: self.driver.switch_to_alert()
49+
except NoAlertPresentException as e: return False
50+
return True
51+
52+
def close_alert_and_get_its_text(self):
53+
try:
54+
alert = self.driver.switch_to_alert()
55+
alert_text = alert.text
56+
if self.accept_next_alert:
57+
alert.accept()
58+
else:
59+
alert.dismiss()
60+
return alert_text
61+
finally: self.accept_next_alert = True
62+
63+
def tearDown(self):
64+
self.driver.quit()
65+
self.assertEqual([], self.verificationErrors)
66+
67+
if __name__ == "__main__":
68+
unittest.main()

gadgets/standard_revisions-tests/hides-dsc-items-with-explicit-mark.html

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)