|
9 | 9 | from selenium.webdriver.support import expected_conditions as EC |
10 | 10 |
|
11 | 11 |
|
12 | | - |
| 12 | +HEADLESS = False |
13 | 13 |
|
14 | 14 | class TestKeywords(unittest.TestCase): |
15 | 15 | def setUp(self): |
16 | 16 | # Initialize the Firefox driver with headless option setting to True. |
17 | 17 | options = webdriver.FirefoxOptions() |
18 | | - options.add_argument('--headless') |
| 18 | + if HEADLESS: |
| 19 | + options.add_argument('--headless') |
19 | 20 |
|
20 | 21 | self.driver = webdriver.Firefox(options=options) |
21 | 22 | def tearDown(self): |
@@ -106,7 +107,8 @@ class TestNosy(unittest.TestCase): |
106 | 107 | def setUp(self): |
107 | 108 | # Initialize the Firefox driver with headless option setting to True. |
108 | 109 | options = webdriver.FirefoxOptions() |
109 | | - options.add_argument('--headless') |
| 110 | + if HEADLESS: |
| 111 | + options.add_argument('--headless') |
110 | 112 |
|
111 | 113 | self.driver = webdriver.Firefox(options=options) |
112 | 114 |
|
@@ -227,7 +229,8 @@ class TestNosy1(unittest.TestCase): |
227 | 229 | def setUp(self): |
228 | 230 | # Initialize the Firefox driver with headless option setting to True. |
229 | 231 | options = webdriver.FirefoxOptions() |
230 | | - options.add_argument('--headless') |
| 232 | + if HEADLESS: |
| 233 | + options.add_argument('--headless') |
231 | 234 |
|
232 | 235 | self.driver = webdriver.Firefox(options=options) |
233 | 236 |
|
@@ -350,7 +353,8 @@ class TestSuperseder(unittest.TestCase): |
350 | 353 |
|
351 | 354 | def setUp(self): |
352 | 355 | options = webdriver.FirefoxOptions() |
353 | | - options.add_argument('--headless') |
| 356 | + if HEADLESS: |
| 357 | + options.add_argument('--headless') |
354 | 358 |
|
355 | 359 | self.driver = webdriver.Firefox(options=options) |
356 | 360 |
|
@@ -439,7 +443,8 @@ class TestSupersederWithKeywords(unittest.TestCase): |
439 | 443 |
|
440 | 444 | def setUp(self): |
441 | 445 | options = webdriver.FirefoxOptions() |
442 | | - options.add_argument('--headless') |
| 446 | + if HEADLESS: |
| 447 | + options.add_argument('--headless') |
443 | 448 |
|
444 | 449 | self.driver = webdriver.Firefox(options=options) |
445 | 450 |
|
@@ -538,7 +543,57 @@ def test_Untitled1(self): |
538 | 543 | print("Test Case 5 -- success") |
539 | 544 |
|
540 | 545 |
|
| 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() |
541 | 576 |
|
| 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") |
542 | 597 |
|
543 | 598 |
|
544 | 599 |
|
|
0 commit comments