Skip to content

Commit bf6ae85

Browse files
authored
Merge pull request #2199 from seleniumbase/refactor-code-and-refresh-dependencies
Refactor code and refresh dependencies
2 parents be6ab2a + b1c415e commit bf6ae85

18 files changed

+180
-61
lines changed

examples/proxy_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_proxy(self):
2222
# This page takes too long to load otherwise
2323
self.get_new_driver(page_load_strategy="none")
2424
self.open("https://ipinfo.io/")
25+
self.wait_for_non_empty_text("form input", timeout=20)
2526
ip_address = self.get_text('#ip-string span[class*="primary"] span')
2627
print("\n\nMy IP Address = %s\n" % ip_address)
2728
print("Displaying Host Info:")

examples/test_hack_search.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def test_hack_search(self):
2525
self.highlight_click('[href*="github.com/seleniumbase/SeleniumBase"]')
2626
self.highlight_click('[href="/seleniumbase/SeleniumBase"]')
2727
self.highlight_click('a[title="examples"]')
28-
self.assert_text("examples", "#file-name-id")
29-
self.highlight_click('div[title="test_hack_search.py"] a')
30-
self.assert_text("test_hack_search.py", "#file-name-id")
31-
self.highlight("#file-name-id")
28+
self.assert_text("examples", "#file-name-id-wide")
29+
self.highlight('a[aria-describedby="item-type-test_hack_search.py"]')
30+
self.click('a[aria-describedby="item-type-test_hack_search.py"]')
31+
self.assert_text("test_hack_search.py", "#file-name-id-wide")
32+
self.highlight("#file-name-id-wide")

help_docs/features_list.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- SeleniumBase Docs -->
22

3-
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=Sjzq9kU5kOw"><img src="http://img.youtube.com/vi/Sjzq9kU5kOw/0.jpg" title="SeleniumBase on YouTube" width="285" /></a>
4-
<!-- GitHub Only --><p>(<b><a href="https://www.youtube.com/watch?v=Sjzq9kU5kOw">Watch the tutorial on YouTube</a></b>)</p>
3+
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=EablmOazy-k"><img src="http://img.youtube.com/vi/EablmOazy-k/0.jpg" title="SeleniumBase on YouTube" width="285" /></a>
4+
<!-- GitHub Only --><p>(<b><a href="https://www.youtube.com/watch?v=EablmOazy-k">Watch the new tutorial on YouTube</a></b>)</p>
55

66
<a id="feature_list"></a>
77

@@ -53,6 +53,8 @@
5353
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=yEQeAU_mrg0"><img src="http://img.youtube.com/vi/yEQeAU_mrg0/0.jpg" title="SeleniumBase on YouTube" width="285" /></a>
5454
<!-- GitHub Only --><p>(<b><a href="https://www.youtube.com/watch?v=yEQeAU_mrg0">Have fun with test automation!</a></b>)</p>
5555

56+
(<b><a href="https://www.youtube.com/watch?v=Sjzq9kU5kOw">Watch the old tutorial on YouTube</a></b>)
57+
5658
<p align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/sb_logo_10.png" alt="SeleniumBase" title="SeleniumBase" width="200"></a></p>
5759

5860
[<img src="https://seleniumbase.github.io/cdn/img/super_logo_sb.png" title="SeleniumBase" width="200">](https://seleniumbase.io/)

help_docs/method_summary.md

Lines changed: 98 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,9 @@ self.add_slide(
635635
content=None, image=None, code=None, iframe=None,
636636
content2=None, notes=None, transition=None, name=None)
637637

638-
self.save_presentation(
639-
name=None, filename=None, show_notes=False, interval=0)
638+
self.save_presentation(name=None, filename=None, show_notes=False, interval=0)
640639

641-
self.begin_presentation(
642-
name=None, filename=None, show_notes=False, interval=0)
640+
self.begin_presentation(name=None, filename=None, show_notes=False, interval=0)
643641

644642
############
645643

@@ -692,8 +690,7 @@ self.create_introjs_tour(name=None)
692690

693691
self.set_introjs_colors(theme_color=None, hover_color=None)
694692

695-
self.add_tour_step(
696-
message, selector=None, name=None, title=None, theme=None, alignment=None)
693+
self.add_tour_step(message, selector=None, name=None, title=None, theme=None, alignment=None)
697694

698695
self.play_tour(name=None, interval=0)
699696
# Duplicates:
@@ -727,8 +724,7 @@ self.post_success_message(message, duration=None, pause=True)
727724

728725
self.post_error_message(message, duration=None, pause=True)
729726

730-
self.set_messenger_theme(
731-
theme="default", location="default", max_messages="default")
727+
self.set_messenger_theme(theme="default", location="default", max_messages="default")
732728

733729
############
734730

@@ -874,25 +870,21 @@ self.quit_extra_driver(driver=None)
874870

875871
############
876872

877-
self.check_window(
878-
name="default", level=0, baseline=False, check_domain=True, full_diff=False)
873+
self.check_window(name="default", level=0, baseline=False, check_domain=True, full_diff=False)
879874

880875
############
881876

882-
self.deferred_assert_element(
883-
selector, by="css selector", timeout=None, fs=False)
877+
self.deferred_assert_element(selector, by="css selector", timeout=None, fs=False)
884878
# Duplicates:
885879
# self.delayed_assert_element(
886880
# selector, by="css selector", timeout=None, fs=False)
887881

888-
self.deferred_assert_element_present(
889-
selector, by="css selector", timeout=None, fs=False)
882+
self.deferred_assert_element_present(selector, by="css selector", timeout=None, fs=False)
890883
# Duplicates:
891884
# self.delayed_assert_element_present(
892885
# selector, by="css selector", timeout=None, fs=False)
893886

894-
self.deferred_assert_text(
895-
text, selector="html", by="css selector", timeout=None, fs=False)
887+
self.deferred_assert_text(text, selector="html", by="css selector", timeout=None, fs=False)
896888
# Duplicates:
897889
# self.delayed_assert_text(
898890
# text, selector="html", by="css selector", timeout=None, fs=False)
@@ -926,6 +918,96 @@ self.fail(msg=None) # Inherited from "unittest"
926918
self._check_browser() # Fails test cleanly if the active window is closed
927919

928920
self._print(TEXT) # Calls Python's print() / Allows for translations
921+
922+
############
923+
924+
# "driver"-specific methods added by SeleniumBase
925+
926+
driver.default_get(url) # Because driver.get(url) works differently in UC Mode
927+
928+
driver.open(url) # Like driver.get(), but allows partial URLs without protocol
929+
930+
driver.click(selector)
931+
932+
driver.click_link(link_text)
933+
934+
driver.click_if_visible(selector)
935+
936+
driver.click_active_element()
937+
938+
driver.send_keys(selector, text)
939+
940+
driver.press_keys(selector, text)
941+
942+
driver.type(selector, text)
943+
944+
driver.submit(selector)
945+
946+
driver.assert_element(selector)
947+
948+
driver.assert_element_present(selector)
949+
950+
driver.assert_element_not_visible(selector)
951+
952+
driver.assert_text(text, selector)
953+
954+
driver.assert_exact_text(text, selector)
955+
956+
driver.wait_for_element(selector)
957+
958+
driver.wait_for_text(text, selector)
959+
960+
driver.wait_for_exact_text(text, selector)
961+
962+
driver.wait_for_and_accept_alert()
963+
964+
driver.wait_for_and_dismiss_alert()
965+
966+
driver.is_element_present(selector)
967+
968+
driver.is_element_visible(selector)
969+
970+
driver.is_text_visible(text, selector)
971+
972+
driver.is_exact_text_visible(text, selector)
973+
974+
driver.is_attribute_present(selector, attribute)
975+
976+
driver.get_text(selector)
977+
978+
driver.js_click(selector)
979+
980+
driver.get_active_element_css()
981+
982+
driver.get_locale_code()
983+
984+
driver.get_origin()
985+
986+
driver.get_user_agent()
987+
988+
driver.highlight(selector)
989+
990+
driver.highlight_click(selector)
991+
992+
driver.sleep(seconds)
993+
994+
driver.get_page_source()
995+
996+
driver.get_title()
997+
998+
############
999+
1000+
# "driver"-specific methods added by SeleniumBase for UC Mode: "--uc" / uc=True
1001+
1002+
driver.uc_open(url)
1003+
1004+
driver.uc_open_with_tab(url)
1005+
1006+
driver.uc_open_with_reconnect(url, reconnect_time=None)
1007+
1008+
driver.uc_click(selector)
1009+
1010+
############
9291011
```
9301012

9311013
--------

help_docs/recorder_mode.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
<img src="https://seleniumbase.github.io/cdn/img/sb_recorder_notification.png" title="SeleniumBase" width="380">
1111

12-
⏺️ To make a new recording with Recorder Mode, use ``sbase mkrec``, ``sbase codegen``, or ``sbase record``):
12+
ℹ️ Recorder Mode can be activated from the command-line interface, or from the Recorder Desktop App.
13+
14+
⏺️ To make a new recording from the command-line interface, use ``sbase mkrec``, ``sbase codegen``, or ``sbase record``):
1315

1416
```bash
1517
sbase mkrec TEST_NAME.py --url=URL
@@ -46,20 +48,20 @@ pytest new_test.py --rec -q -s --url=wikipedia.org
4648
*** RECORDING COPIED to: new_test.py
4749
```
4850
49-
🔴 You can also activate Recorder Mode from the Desktop App:
51+
🔴 You can also activate Recorder Mode from the Recorder Desktop App:
5052
5153
```bash
5254
sbase recorder
5355
* Starting the SeleniumBase Recorder Desktop App...
5456
```
5557
56-
<img src="https://seleniumbase.github.io/cdn/img/recorder_desktop.png" title="SeleniumBase" width="340">
58+
<img src="https://seleniumbase.github.io/cdn/img/recorder_desktop_2.png" title="SeleniumBase" width="340">
5759
5860
⏺️ While a recording is in progress, you can press the ``[ESC]`` key to pause the Recorder. To resume the recording, you can hit the ``[~`]`` key, which is located directly below the ``[ESC]`` key on most keyboards.
5961
6062
⏺️ From within Recorder Mode there are two additional modes: "Assert Element Mode" and "Assert Text Mode". To switch into "Assert Element Mode", press the ``[^]-key (SHIFT+6)``: The border will become purple, and you'll be able to click on elements to assert from your test. To switch into "Assert Text Mode", press the ``[&]-key (SHIFT+7)``: The border will become teal, and you'll be able to click on elements for asserting text from your test.
6163
62-
While using either of the two special Assertion Modes, certain actions such as clicking on links won't have any effect. This lets you make assertions on elements without navigating away from the page, etc. To add an assertion for buttons without triggering default "click" behavior, mouse-down on the button and then mouse-up somewhere else. (This prevents a detected click while still recording the assert.) To return back to the original Recorder Mode, press any key other than ``[SHIFT]`` or ``[BACKSPACE]`` (Eg: Press ``[CONTROL]``, etc.). Press ``[ESC]`` once to leave the Assertion Modes, but it'll stop the Recorder if you press it again.
64+
⏺️ While using either of the two special Assertion Modes, certain actions such as clicking on links won't have any effect. This lets you make assertions on elements without navigating away from the page, etc. To add an assertion for buttons without triggering default "click" behavior, mouse-down on the button and then mouse-up somewhere else. (This prevents a detected click while still recording the assert.) To return back to the original Recorder Mode, press any key other than ``[SHIFT]`` or ``[BACKSPACE]`` (Eg: Press ``[CONTROL]``, etc.). Press ``[ESC]`` once to leave the Assertion Modes, but it'll stop the Recorder if you press it again.
6365
6466
⏺️ For extra flexibility, the ``sbase mkrec`` command can be split into four separate commands:
6567

mkdocs_build/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ mkdocs==1.5.3
2323
mkdocs-material==9.4.6
2424
mkdocs-exclude-search==0.6.5
2525
mkdocs-simple-hooks==0.1.5
26-
mkdocs-material-extensions==1.2
26+
mkdocs-material-extensions==1.3

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pip>=23.2.1
1+
pip>=23.3
22
packaging>=23.2
33
setuptools>=68.0.0;python_version<"3.8"
44
setuptools>=68.2.2;python_version>="3.8"
@@ -14,13 +14,13 @@ six==1.16.0
1414
idna==3.4
1515
chardet==5.2.0
1616
charset-normalizer==3.3.0
17-
urllib3>=1.26.16,<2;python_version<"3.10"
18-
urllib3>=1.26.16,<2.1.0;python_version>="3.10"
17+
urllib3>=1.26.18,<2;python_version<"3.10"
18+
urllib3>=1.26.18,<2.1.0;python_version>="3.10"
1919
requests==2.31.0
2020
pynose==1.4.8
2121
sniffio==1.3.0
2222
h11==0.14.0
23-
outcome==1.2.0
23+
outcome==1.3.0
2424
trio==0.22.2
2525
trio-websocket==0.11.1
2626
wsproto==1.2.0

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.20.3"
2+
__version__ = "4.20.4"

seleniumbase/config/proxy_list.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
"""
2424

2525
PROXY_LIST = {
26-
"example1": "151.181.91.10:80", # (Example) - set your own proxy here
27-
"example2": "socks4://50.197.210.138:32100", # (Example)
26+
"example1": "138.199.48.1:8443", # (Example) - set your own proxy here
27+
"example2": "socks4://167.71.100.140:55229", # (Example)
28+
"example3": "socks5://167.172.159.43:49633", # (Example)
2829
"proxy1": None,
2930
"proxy2": None,
3031
"proxy3": None,

seleniumbase/core/browser_launcher.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,7 @@ def uc_special_open_if_cf(
329329
device_height=None,
330330
device_pixel_ratio=None,
331331
):
332-
if (
333-
url.startswith("http:") or url.startswith("https:")
334-
):
332+
if url.startswith("http:") or url.startswith("https:"):
335333
special = False
336334
try:
337335
req_get = requests_get(url, proxy_string)
@@ -427,6 +425,13 @@ def uc_open_with_reconnect(driver, url, reconnect_time=None):
427425
return None
428426

429427

428+
def uc_click(
429+
driver, selector, by="css selector", timeout=settings.SMALL_TIMEOUT
430+
):
431+
element = driver.wait_for_element(selector, by=by, timeout=timeout)
432+
element.uc_click()
433+
434+
430435
def edgedriver_on_path():
431436
return os.path.exists(LOCAL_EDGEDRIVER)
432437

@@ -3485,6 +3490,9 @@ def get_local_driver(
34853490
driver, *args, **kwargs
34863491
)
34873492
)
3493+
driver.uc_click = lambda *args, **kwargs: uc_click(
3494+
driver, *args, **kwargs
3495+
)
34883496
if mobile_emulator:
34893497
uc_metrics = {}
34903498
if (

0 commit comments

Comments
 (0)