|
6 | 6 |
|
7 | 7 |
|
8 | 8 | class UndetectedTest(BaseCase): |
9 | | - def verify_success(self): |
10 | | - self.assert_text("OH YEAH, you passed!", "h1", timeout=6.25) |
11 | | - self.post_message("Selenium wasn't detected!", duration=2.8) |
12 | | - self._print("\n Success! Website did not detect Selenium! ") |
13 | | - |
14 | | - def fail_me(self): |
15 | | - self.fail('Selenium was detected! Try using: "pytest --uc"') |
16 | | - |
17 | 9 | def test_browser_is_undetected(self): |
18 | | - if not (self.undetectable): |
| 10 | + if not self.undetectable: |
19 | 11 | self.get_new_driver(undetectable=True) |
20 | | - self.driver.get("https://nowsecure.nl/#relax") |
21 | | - try: |
22 | | - self.verify_success() |
23 | | - except Exception: |
24 | | - self.clear_all_cookies() |
| 12 | + self.driver.uc_open_with_reconnect( |
| 13 | + "https://nowsecure.nl/#relax", reconnect_time=3 |
| 14 | + ) |
| 15 | + self.sleep(1.2) |
| 16 | + if not self.is_text_visible("OH YEAH, you passed!", "h1"): |
25 | 17 | self.get_new_driver(undetectable=True) |
26 | | - self.driver.get("https://nowsecure.nl/#relax") |
27 | | - try: |
28 | | - self.verify_success() |
29 | | - except Exception: |
30 | | - if self.is_element_visible('iframe[src*="challenge"]'): |
31 | | - with self.frame_switch('iframe[src*="challenge"]'): |
32 | | - self.click("span.mark") |
33 | | - else: |
34 | | - self.fail_me() |
35 | | - try: |
36 | | - self.verify_success() |
37 | | - except Exception: |
38 | | - self.fail_me() |
| 18 | + self.driver.uc_open_with_reconnect( |
| 19 | + "https://nowsecure.nl/#relax", reconnect_time=3 |
| 20 | + ) |
| 21 | + self.sleep(1.2) |
| 22 | + if not self.is_text_visible("OH YEAH, you passed!", "h1"): |
| 23 | + if self.is_element_visible('iframe[src*="challenge"]'): |
| 24 | + with self.frame_switch('iframe[src*="challenge"]'): |
| 25 | + self.click("span.mark") |
| 26 | + self.sleep(2) |
| 27 | + self.assert_text("OH YEAH, you passed!", "h1", timeout=3) |
| 28 | + self.post_message("Selenium wasn't detected!", duration=2.8) |
| 29 | + self._print("\n Success! Website did not detect Selenium! ") |
0 commit comments