Skip to content

Commit 0a8666a

Browse files
committed
Update examples
1 parent 4c1cce4 commit 0a8666a

File tree

4 files changed

+35
-33
lines changed

4 files changed

+35
-33
lines changed

examples/ReadMe.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,34 @@
1919

2020
--------
2121

22-
Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py): (Default option: ``--chrome``)
22+
Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py): (Default option: ``--chrome``)
2323

2424
```bash
25-
pytest test_demo_site.py
25+
pytest my_first_test.py
2626
```
2727

28-
<img src="https://seleniumbase.github.io/cdn/gif/demo_page_4.gif" title="SeleniumBase Demo Page" /><br />
28+
<img src="https://seleniumbase.github.io/cdn/gif/fast_swag.gif" title="SeleniumBase Demo Page" /><br />
2929

3030
--------
3131

32-
Run an example test in Firefox:
32+
Here's one way of changing the browser to Firefox:
3333

3434
```bash
35-
pytest my_first_test.py --browser=firefox
35+
pytest my_first_test.py --firefox
3636
```
3737

3838
--------
3939

40+
Another [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py) for a web page that has lots of different HTML items:
41+
42+
```bash
43+
pytest test_demo_site.py
44+
```
45+
46+
<img src="https://seleniumbase.github.io/cdn/gif/demo_page_4.gif" title="SeleniumBase Demo Page" /><br />
47+
48+
--------
49+
4050
Run an example test in ``--demo`` mode: (highlight assertions)
4151

4252
```bash

examples/example_logs/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ python -m http.server 1948
4545
🔵 Here's a full example of what the SeleniumBase Dashboard may look like:
4646

4747
```bash
48-
pytest test_suite.py --dashboard --rs --headless
48+
pytest test_suite.py test_image_saving.py --dashboard --rs --headless
4949
```
5050

5151
<img src="https://seleniumbase.github.io/cdn/img/dashboard_2.png" alt="The SeleniumBase Dashboard" title="The SeleniumBase Dashboard" width="480" />

examples/hack_the_planet.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_all_your_base_are_belong_to_us(self):
3838
self.set_text_content('#shelf-1 a[href*="mac"]', "ALL")
3939
self.set_text_content('#shelf-1 a[href*="iphone"]', "YOUR")
4040
self.set_text_content('#shelf-1 a[href*="ipad"]', "BASE")
41+
self.remove_element('#shelf-1 [role="listitem"]:nth-child(5)')
4142
self.set_text_content('#shelf-1 a[href*="watch"]', "ARE")
4243
self.set_text_content('#shelf-1 a[href*="airpods"]', "BELONG")
4344
self.set_text_content('#shelf-1 a[href*="airtag"]', "TO")

examples/verify_undetected.py

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,24 @@
66

77

88
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-
179
def test_browser_is_undetected(self):
18-
if not (self.undetectable):
10+
if not self.undetectable:
1911
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"):
2517
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

Comments
 (0)