Skip to content

Commit 3a5b1b4

Browse files
authored
Merge pull request #1992 from seleniumbase/dependencies-and-uc-mode-updates
Update UC Mode, JS methods, and dependencies
2 parents c329b5b + 30ddf1c commit 3a5b1b4

File tree

12 files changed

+68
-45
lines changed

12 files changed

+68
-45
lines changed

examples/translations/ReadMe.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class 我的测试类(硒测试用例):
1919
self.输入文本('input[name="search"]', "舞龍")
2020
self.单击('button:contains("搜索")')
2121
self.断言文本("舞龍", "#firstHeading")
22+
self.断言元素('img[src*="Chinese_draak.jpg"]')
2223
```
2324

2425
Here's another example:
@@ -36,6 +37,9 @@ class 私のテストクラス(セレニウムテストケース):
3637
self.クリックして("#searchform button")
3738
self.テキストを確認する("アニメ", "#firstHeading")
3839
self.JS入力('input[name="search"]', "寿司")
40+
self.クリックして("#searchform button")
41+
self.テキストを確認する("寿司", "#firstHeading")
42+
self.要素を確認する('img[alt="握り寿司"]')
3943
```
4044

4145
<a id="translation_api"></a>

examples/translations/chinese_test_1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ def test_例子1(self):
1313
self.单击('button:contains("搜索")')
1414
self.断言文本("舞龍", "#firstHeading")
1515
self.断言元素('img[src*="Chinese_draak.jpg"]')
16+
self.回去()
1617
self.输入文本('input[name="search"]', "麻婆豆腐")
1718
self.单击('button:contains("搜索")')
1819
self.断言文本("麻婆豆腐", "#firstHeading")
1920
self.断言元素('figure:contains("一家中餐館的麻婆豆腐")')
21+
self.回去()
2022
self.输入文本('input[name="search"]', "精武英雄")
2123
self.单击('button:contains("搜索")')
2224
self.断言元素('img[src*="Fist_of_legend.jpg"]')

examples/uc_cdp_events.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
if __name__ == "__main__":
55
from pytest import main
6-
main([__file__, "--uc", "--uc-cdp", "--incognito", "-s"])
6+
main([__file__, "--uc", "--uc-cdp", "-s"])
77

88

99
class CDPTests(BaseCase):
@@ -23,10 +23,8 @@ def fail_me(self):
2323
self.fail('Selenium was detected! Try using: "pytest --uc"')
2424

2525
def test_display_cdp_events(self):
26-
if not (self.undetectable and self.uc_cdp_events and self.incognito):
27-
self.get_new_driver(
28-
undetectable=True, uc_cdp_events=True, incognito=True
29-
)
26+
if not (self.undetectable and self.uc_cdp_events):
27+
self.get_new_driver(undetectable=True, uc_cdp_events=True)
3028
self.open("https://nowsecure.nl/#relax")
3129
try:
3230
self.verify_success()

help_docs/method_summary.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,17 @@ self.scroll_to_bottom()
383383

384384
self.click_xpath(xpath)
385385

386-
self.js_click(selector, by="css selector", all_matches=False, scroll=True)
386+
self.js_click(selector, by="css selector", all_matches=False, timeout=None, scroll=True)
387387

388388
self.js_click_if_present(selector, by="css selector", timeout=0)
389389

390390
self.js_click_if_visible(selector, by="css selector", timeout=0)
391391

392-
self.js_click_all(selector, by="css selector")
392+
self.js_click_all(selector, by="css selector", timeout=None)
393393

394-
self.jquery_click(selector, by="css selector")
394+
self.jquery_click(selector, by="css selector", timeout=None)
395395

396-
self.jquery_click_all(selector, by="css selector")
396+
self.jquery_click_all(selector, by="css selector", timeout=None)
397397

398398
self.hide_element(selector, by="css selector")
399399

help_docs/syntax_formats.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,12 @@ class 我的测试类(硒测试用例):
415415
self.单击('button:contains("搜索")')
416416
self.断言文本("舞龍", "#firstHeading")
417417
self.断言元素('img[src*="Chinese_draak.jpg"]')
418+
self.回去()
418419
self.输入文本('input[name="search"]', "麻婆豆腐")
419420
self.单击('button:contains("搜索")')
420421
self.断言文本("麻婆豆腐", "#firstHeading")
421422
self.断言元素('figure:contains("一家中餐館的麻婆豆腐")')
423+
self.回去()
422424
self.输入文本('input[name="search"]', "精武英雄")
423425
self.单击('button:contains("搜索")')
424426
self.断言元素('img[src*="Fist_of_legend.jpg"]')

help_docs/translations.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class 我的测试类(硒测试用例):
2121
self.输入文本('input[name="search"]', "舞龍")
2222
self.单击('button:contains("搜索")')
2323
self.断言文本("舞龍", "#firstHeading")
24+
self.断言元素('img[src*="Chinese_draak.jpg"]')
2425
```
2526

2627
Here's another example:
@@ -38,6 +39,9 @@ class 私のテストクラス(セレニウムテストケース):
3839
self.クリックして("#searchform button")
3940
self.テキストを確認する("アニメ", "#firstHeading")
4041
self.JS入力('input[name="search"]', "寿司")
42+
self.クリックして("#searchform button")
43+
self.テキストを確認する("寿司", "#firstHeading")
44+
self.要素を確認する('img[alt="握り寿司"]')
4145
```
4246

4347
<a id="translation_api"></a>

mkdocs_build/requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# mkdocs dependencies for generating the seleniumbase.io website
22
# Minimum Python version: 3.8 (for generating docs only)
33

4-
regex>=2023.6.3
4+
regex>=2023.8.8
55
pkginfo>=1.9.6
66
PyYAML>=6.0.1
77
readme-renderer>=40.0
@@ -11,6 +11,8 @@ pipdeptree>=2.12.0
1111
bleach>=6.0.0
1212
docutils>=0.20.1
1313
python-dateutil>=2.8.2
14+
tqdm>=4.65.2
15+
nltk>=3.8.1
1416
livereload==2.6.3
1517
joblib==1.3.1
1618
Markdown==3.4.4
@@ -19,7 +21,6 @@ Jinja2==3.1.2
1921
click==8.1.6
2022
ghp-import==2.1.0
2123
lunr==0.6.2
22-
nltk==3.8.1
2324
tornado==6.3.2
2425
watchdog==3.0.0
2526
cairocffi==1.6.1

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ urllib3>=1.26.16,<2;python_version>="3.7" and python_version<"3.10"
2626
urllib3>=1.26.16,<2.1.0;python_version>="3.10"
2727
requests==2.27.1;python_version<"3.7"
2828
requests==2.31.0;python_version>="3.7"
29-
pynose==1.4.7
29+
pynose==1.4.8
3030
sniffio==1.3.0;python_version>="3.7"
3131
h11==0.14.0;python_version>="3.7"
3232
outcome==1.2.0;python_version>="3.7"
@@ -67,10 +67,10 @@ soupsieve==2.3.2.post1;python_version<"3.7"
6767
soupsieve==2.4.1;python_version>="3.7"
6868
beautifulsoup4==4.12.2
6969
pygments==2.14.0;python_version<"3.7"
70-
pygments==2.15.1;python_version>="3.7"
70+
pygments==2.16.1;python_version>="3.7"
7171
pyreadline3==3.4.1;platform_system=="Windows"
7272
tabcompleter==1.2.1
73-
pdbp==1.4.3
73+
pdbp==1.4.4
7474
colorama==0.4.5;python_version<"3.7"
7575
colorama==0.4.6;python_version>="3.7"
7676
exceptiongroup==1.1.2;python_version>="3.7"

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.17.1"
2+
__version__ = "4.17.2"

seleniumbase/fixtures/base_case.py

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5687,13 +5687,22 @@ def click_xpath(self, xpath):
56875687
self.click(xpath, by="xpath")
56885688

56895689
def js_click(
5690-
self, selector, by="css selector", all_matches=False, scroll=True
5690+
self,
5691+
selector,
5692+
by="css selector",
5693+
all_matches=False,
5694+
timeout=None,
5695+
scroll=True,
56915696
):
56925697
"""Clicks an element using JavaScript.
56935698
Can be used to click hidden / invisible elements.
56945699
If "all_matches" is False, only the first match is clicked.
56955700
If "scroll" is False, won't scroll unless running in Demo Mode."""
56965701
self.wait_for_ready_state_complete()
5702+
if not timeout or timeout is True:
5703+
timeout = settings.SMALL_TIMEOUT
5704+
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
5705+
timeout = self.__get_new_timeout(timeout)
56975706
selector, by = self.__recalculate_selector(selector, by, xp_ok=False)
56985707
if by == By.LINK_TEXT:
56995708
message = (
@@ -5706,7 +5715,7 @@ def js_click(
57065715
self.click(selector, by=by)
57075716
return
57085717
element = self.wait_for_element_present(
5709-
selector, by=by, timeout=settings.SMALL_TIMEOUT
5718+
selector, by=by, timeout=timeout
57105719
)
57115720
if not page_actions.is_element_clickable(self.driver, selector, by):
57125721
self.wait_for_ready_state_complete()
@@ -5818,9 +5827,7 @@ def js_click_if_present(self, selector, by="css selector", timeout=0):
58185827
self.js_click(selector, by=by)
58195828
elif timeout > 0:
58205829
try:
5821-
self.wait_for_element_present(
5822-
selector, by=by, timeout=timeout
5823-
)
5830+
self.wait_for_element_present(selector, by=by, timeout=timeout)
58245831
except Exception:
58255832
pass
58265833
if self.is_element_present(selector, by=by):
@@ -5836,27 +5843,29 @@ def js_click_if_visible(self, selector, by="css selector", timeout=0):
58365843
self.js_click(selector, by=by)
58375844
elif timeout > 0:
58385845
try:
5839-
self.wait_for_element_visible(
5840-
selector, by=by, timeout=timeout
5841-
)
5846+
self.wait_for_element_visible(selector, by=by, timeout=timeout)
58425847
except Exception:
58435848
pass
58445849
if self.is_element_visible(selector, by=by):
58455850
self.js_click(selector, by=by)
58465851

5847-
def js_click_all(self, selector, by="css selector"):
5852+
def js_click_all(self, selector, by="css selector", timeout=None):
58485853
"""Clicks all matching elements using pure JS. (No jQuery)"""
5849-
self.js_click(selector, by="css selector", all_matches=True)
5854+
self.js_click(
5855+
selector, by="css selector", all_matches=True, timeout=timeout
5856+
)
58505857

5851-
def jquery_click(self, selector, by="css selector"):
5858+
def jquery_click(self, selector, by="css selector", timeout=None):
58525859
"""Clicks an element using jQuery. (Different from using pure JS.)
58535860
Can be used to click hidden / invisible elements."""
58545861
self.__check_scope()
5862+
if not timeout or timeout is True:
5863+
timeout = settings.SMALL_TIMEOUT
5864+
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
5865+
timeout = self.__get_new_timeout(timeout)
58555866
original_selector = selector
58565867
selector, by = self.__recalculate_selector(selector, by, xp_ok=False)
5857-
self.wait_for_element_present(
5858-
selector, by=by, timeout=settings.SMALL_TIMEOUT
5859-
)
5868+
self.wait_for_element_present(selector, by=by, timeout=timeout)
58605869
if self.is_element_visible(selector, by=by):
58615870
self.__demo_mode_highlight_if_active(selector, by)
58625871
selector = self.convert_to_css_selector(selector, by=by)
@@ -5887,14 +5896,16 @@ def jquery_click(self, selector, by="css selector"):
58875896
self.safe_execute_script(click_script)
58885897
self.__demo_mode_pause_if_active()
58895898

5890-
def jquery_click_all(self, selector, by="css selector"):
5899+
def jquery_click_all(self, selector, by="css selector", timeout=None):
58915900
"""Clicks all matching elements using jQuery."""
58925901
self.__check_scope()
5902+
if not timeout or timeout is True:
5903+
timeout = settings.SMALL_TIMEOUT
5904+
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
5905+
timeout = self.__get_new_timeout(timeout)
58935906
original_selector = selector
58945907
selector, by = self.__recalculate_selector(selector, by, xp_ok=False)
5895-
self.wait_for_element_present(
5896-
selector, by=by, timeout=settings.SMALL_TIMEOUT
5897-
)
5908+
self.wait_for_element_present(selector, by=by, timeout=timeout)
58985909
if self.is_element_visible(selector, by=by):
58995910
self.__demo_mode_highlight_if_active(selector, by)
59005911
css_selector = self.convert_to_css_selector(selector, by=by)

0 commit comments

Comments
 (0)