Skip to content

Commit cd3e443

Browse files
committed
test fallback mechanism Issue #16
1 parent 57fcde0 commit cd3e443

File tree

1 file changed

+61
-6
lines changed

1 file changed

+61
-6
lines changed

test_classhelper.py

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
from selenium.webdriver.support import expected_conditions as EC
1010

1111

12-
12+
HEADLESS = False
1313

1414
class TestKeywords(unittest.TestCase):
1515
def setUp(self):
1616
# Initialize the Firefox driver with headless option setting to True.
1717
options = webdriver.FirefoxOptions()
18-
options.add_argument('--headless')
18+
if HEADLESS:
19+
options.add_argument('--headless')
1920

2021
self.driver = webdriver.Firefox(options=options)
2122
def tearDown(self):
@@ -106,7 +107,8 @@ class TestNosy(unittest.TestCase):
106107
def setUp(self):
107108
# Initialize the Firefox driver with headless option setting to True.
108109
options = webdriver.FirefoxOptions()
109-
options.add_argument('--headless')
110+
if HEADLESS:
111+
options.add_argument('--headless')
110112

111113
self.driver = webdriver.Firefox(options=options)
112114

@@ -227,7 +229,8 @@ class TestNosy1(unittest.TestCase):
227229
def setUp(self):
228230
# Initialize the Firefox driver with headless option setting to True.
229231
options = webdriver.FirefoxOptions()
230-
options.add_argument('--headless')
232+
if HEADLESS:
233+
options.add_argument('--headless')
231234

232235
self.driver = webdriver.Firefox(options=options)
233236

@@ -350,7 +353,8 @@ class TestSuperseder(unittest.TestCase):
350353

351354
def setUp(self):
352355
options = webdriver.FirefoxOptions()
353-
options.add_argument('--headless')
356+
if HEADLESS:
357+
options.add_argument('--headless')
354358

355359
self.driver = webdriver.Firefox(options=options)
356360

@@ -439,7 +443,8 @@ class TestSupersederWithKeywords(unittest.TestCase):
439443

440444
def setUp(self):
441445
options = webdriver.FirefoxOptions()
442-
options.add_argument('--headless')
446+
if HEADLESS:
447+
options.add_argument('--headless')
443448

444449
self.driver = webdriver.Firefox(options=options)
445450

@@ -538,7 +543,57 @@ def test_Untitled1(self):
538543
print("Test Case 5 -- success")
539544

540545

546+
class TestFallbackMechanism(unittest.TestCase):
547+
def setUp(self):
548+
options = webdriver.FirefoxOptions()
549+
if HEADLESS:
550+
options.add_argument('--headless')
551+
552+
self.driver = webdriver.Firefox(options=options)
553+
554+
def tearDown(self):
555+
self.driver.quit()
556+
557+
def test_demo(self):
558+
wait = WebDriverWait(self.driver, 10)
559+
560+
# Open URL /demo/
561+
self.driver.get("http://localhost:8917/demo/")
562+
563+
# Set window size
564+
self.driver.set_window_size(786, 824)
565+
566+
# Click on element with name '__login_name'
567+
wait.until(EC.element_to_be_clickable((By.NAME, "__login_name"))).click()
568+
# Type "admin" into the element with name attribute equal to "__login_name"
569+
self.driver.find_element(By.NAME, "__login_name").send_keys("admin")
570+
571+
# Type "admin" into the element with name attribute equal to "__login_password"
572+
self.driver.find_element(By.NAME, "__login_password").send_keys("admin")
573+
574+
# Click on the element with CSS selector ".userblock > input:nth-child(12)"
575+
self.driver.find_element(By.CSS_SELECTOR, ".userblock > input:nth-child(12)").click()
541576

577+
# Click on element with link text 'Create New'
578+
wait.until(EC.element_to_be_clickable((By.LINK_TEXT, "Create New"))).click()
579+
580+
print(self.driver.current_url)
581+
self.driver.get(self.driver.current_url + "#classhelper-wc-toggle")
582+
self.driver.execute_script("location.reload()")
583+
584+
time.sleep(3)
585+
586+
# Click on element with link text '(list)'
587+
wait.until(EC.presence_of_element_located((By.LINK_TEXT, "(list)"))).click()
588+
589+
main_window_handle = self.driver.current_window_handle
590+
591+
# Switch to the popup window
592+
for handle in self.driver.window_handles:
593+
if handle != main_window_handle:
594+
self.driver.switch_to.window(handle)
595+
596+
self.assertEqual(self.driver.title, "superseder help - Roundup issue tracker")
542597

543598

544599

0 commit comments

Comments
 (0)