Skip to content

Commit 4d0e168

Browse files
authored
Merge pull request #4043 from seleniumbase/bug-fixes-and-ai-browser-support
Bug fixes and A.I. browser support
2 parents 6da4191 + 02d48c1 commit 4d0e168

37 files changed

+437
-157
lines changed

examples/boilerplates/samples/test_page_objects.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ def do_search_and_click(self, sb, search_term):
3434

3535
class MyTests(BaseCase):
3636
def test_page_objects(self):
37-
if self.headless and self._multithreaded:
37+
if self.headless:
3838
self.open_if_not_url("about:blank")
39-
print("\n Skipping test in headless multi-threaded mode.")
40-
self.skip("Skipping test in headless multi-threaded mode.")
39+
print("\n Skipping test in headless mode.")
40+
self.skip("Skipping test in headless mode.")
41+
if not self.undetectable:
42+
self.get_new_driver(undetectable=True)
4143
search_term = "SeleniumBase.io Docs"
4244
expected_text = "SeleniumBase"
4345
GooglePage().go_to_google(self)

examples/cdp_mode/raw_cdp_turnstile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
sb = sb_cdp.Chrome(url)
55
sb.gui_click_captcha()
66
sb.assert_element("img#captcha-success")
7-
sb.sleep(2)
7+
sb.set_messenger_theme(location="top_left")
8+
sb.post_message("SeleniumBase wasn't detected", duration=3)
89
sb.driver.stop()

examples/test_hack_search.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ def test_hack_search(self):
1212
self.open_if_not_url("about:blank")
1313
print("\n Skipping test in headless mode.")
1414
self.skip('Skipping test in headless mode.')
15+
if not self.undetectable:
16+
self.get_new_driver(undetectable=True)
1517
self.open("https://google.com/ncr")
1618
self.hide_elements("iframe")
1719
self.assert_element('[title="Search"]')
1820
self.sleep(0.5)
1921
self.set_attribute('[action="/search"]', "action", "//bing.com/search")
2022
self.set_attributes('[value="Google Search"]', "value", "Bing Search")
21-
self.type('[title="Search"]', "GitHub SeleniumBase Docs Install")
23+
self.type('[title="Search"]', "SeleniumBase GitHub Page URL")
2224
self.sleep(0.5)
2325
self.js_click('[value="Bing Search"]')
2426
self.highlight("h1.b_logo", loops=8)
25-
self.highlight_click('[href*="github.com/seleniumbase/SeleniumBase"]')
26-
self.highlight_click('[href="/seleniumbase/SeleniumBase"]')
27-
self.assert_text("SeleniumBase", "strong a")
28-
self.highlight("strong a")
27+
source = self.get_page_source()
28+
self.assert_true("github.com/seleniumbase/SeleniumBase" in source)
29+
self.click('a:contains("seleniumbase/SeleniumBase")')
2930
self.js_click('a[title="examples"]')
3031
self.highlight('#repo-content-turbo-frame')
3132
self.js_click('a[title="test_hack_search.py"]')

help_docs/how_it_works.md

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

55
<a id="how_seleniumbase_works"></a>
66

7-
👁️🔎 The primary [SeleniumBase syntax format](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md) works by extending [pytest](https://docs.pytest.org/en/latest/) as a direct plugin. SeleniumBase automatically spins up web browsers for tests (using [Selenium WebDriver](https://www.selenium.dev/documentation/webdriver/)), and then gives those tests access to the SeleniumBase libraries through the [BaseCase class](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py). Tests are also given access to [SeleniumBase command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) and [SeleniumBase methods](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md), which provide additional functionality.
7+
👁️🔎 The primary [SeleniumBase syntax format](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md) works by extending [pytest](https://docs.pytest.org/en/latest/) as a direct plugin. SeleniumBase automatically spins up web browsers for tests, and then gives those tests access to the SeleniumBase libraries through the [BaseCase class](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py). Tests are also given access to [SeleniumBase command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) and [SeleniumBase methods](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md).
88

99
👁️🔎 ``pytest`` uses a feature called test discovery to automatically find and run Python methods that start with ``test_`` when those methods are located in Python files that start with ``test_`` or end with ``_test.py``.
1010

@@ -50,7 +50,7 @@ BaseCase.main(__name__, __file__)
5050

5151
class TestSimpleLogin(BaseCase):
5252
def test_simple_login(self):
53-
self.open("https://seleniumbase.io/simple/login")
53+
self.open("seleniumbase.io/simple/login")
5454
self.type("#username", "demo_user")
5555
self.type("#password", "secret_pass")
5656
self.click('a:contains("Sign in")')
@@ -80,7 +80,7 @@ from seleniumbase import Driver
8080

8181
driver = Driver()
8282
try:
83-
driver.get("https://seleniumbase.io/simple/login")
83+
driver.open("seleniumbase.io/simple/login")
8484
driver.type("#username", "demo_user")
8585
driver.type("#password", "secret_pass")
8686
driver.click('a:contains("Sign in")')

help_docs/install.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ pip install git+https://github.com/seleniumbase/SeleniumBase.git@master#egg=sele
4747

4848
* (Add ``--upgrade`` OR ``-U`` to upgrade SeleniumBase.)
4949
* (Add ``--force-reinstall`` to upgrade indirect libraries.)
50-
* (Use ``pip3`` if multiple versions of Python are present.)
5150

5251
(If you're not using a virtual environment, you may need to add ``--user`` to your ``pip`` command if you're seeing errors during installation.)
5352

mkdocs_build/prepare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def main(*args, **kwargs):
117117

118118
for file_ in updated_files_to_process:
119119
readme_file = "./mkdocs_build/" + file_
120-
with open(readme_file, "r", encoding="utf-8") as f:
120+
with open(readme_file, mode="r", encoding="utf-8") as f:
121121
all_code = f.read()
122122
code_lines = all_code.split("\n")
123123

@@ -195,6 +195,6 @@ def main(*args, **kwargs):
195195
)
196196
seleniumbase_lines.append(line)
197197
if changed:
198-
out_file = open(readme_file, "w+", encoding="utf-8")
198+
out_file = open(readme_file, mode="w+", encoding="utf-8")
199199
out_file.writelines("\r\n".join(seleniumbase_lines))
200200
out_file.close()

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pyyaml>=6.0.3
3333
pygments>=2.19.2
3434
pyreadline3>=3.5.4;platform_system=="Windows"
3535
tabcompleter>=1.4.0
36-
pdbp>=1.7.1
36+
pdbp>=1.8.0
3737
idna>=3.11
3838
chardet==5.2.0
3939
charset-normalizer>=3.4.4,<4

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.43.1"
2+
__version__ = "4.43.2"

seleniumbase/behave/behave_sb.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,24 +1216,24 @@ def _create_dashboard_assets_():
12161216
add_pytest_style_css = True
12171217
if os.path.exists(pytest_style_css):
12181218
existing_pytest_style = None
1219-
with open(pytest_style_css, "r") as f:
1219+
with open(pytest_style_css, mode="r") as f:
12201220
existing_pytest_style = f.read()
12211221
if existing_pytest_style == get_pytest_style():
12221222
add_pytest_style_css = False
12231223
if add_pytest_style_css:
1224-
out_file = open(pytest_style_css, "w+", encoding="utf-8")
1224+
out_file = open(pytest_style_css, mode="w+", encoding="utf-8")
12251225
out_file.writelines(get_pytest_style())
12261226
out_file.close()
12271227
live_js_file = os.path.join(assets_folder, "live.js")
12281228
add_live_js_file = True
12291229
if os.path.exists(live_js_file):
12301230
existing_live_js = None
1231-
with open(live_js_file, "r") as f:
1231+
with open(live_js_file, mode="r") as f:
12321232
existing_live_js = f.read()
12331233
if existing_live_js == live_js:
12341234
add_live_js_file = False
12351235
if add_live_js_file:
1236-
out_file = open(live_js_file, "w+", encoding="utf-8")
1236+
out_file = open(live_js_file, mode="w+", encoding="utf-8")
12371237
out_file.writelines(live_js)
12381238
out_file.close()
12391239

@@ -1306,7 +1306,7 @@ def _perform_behave_unconfigure_():
13061306
# Part 1: Finalizing the dashboard / integrating html report
13071307
if os.path.exists(dashboard_path):
13081308
the_html_d = None
1309-
with open(dashboard_path, "r", encoding="utf-8") as f:
1309+
with open(dashboard_path, mode="r", encoding="utf-8") as f:
13101310
the_html_d = f.read()
13111311
if sb_config._multithreaded and "-c" in sys.argv:
13121312
# Threads have "-c" in sys.argv, except for the last
@@ -1317,7 +1317,7 @@ def _perform_behave_unconfigure_():
13171317
if os.path.exists(pie_path):
13181318
import json
13191319

1320-
with open(pie_path, "r") as f:
1320+
with open(pie_path, mode="r") as f:
13211321
dash_pie = f.read().strip()
13221322
sb_config._saved_dashboard_pie = json.loads(dash_pie)
13231323
# If the test run doesn't complete by itself, stop refresh
@@ -1326,7 +1326,7 @@ def _perform_behave_unconfigure_():
13261326
the_html_d = the_html_d.replace(find_it_3, swap_with_3)
13271327
the_html_d = the_html_d.replace(find_it_4, swap_with_4)
13281328
the_html_d += stamp
1329-
with open(dashboard_path, "w", encoding="utf-8") as f:
1329+
with open(dashboard_path, mode="w", encoding="utf-8") as f:
13301330
f.write(the_html_d) # Finalize the dashboard
13311331
except KeyboardInterrupt:
13321332
pass

seleniumbase/console_scripts/sb_caseplans.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def generate_case_plan_boilerplates(
134134
file_name = case_id
135135
file_path = os.path.join(full_folder_path, file_name)
136136
if not os.path.exists(file_path):
137-
out_file = open(file_path, "w+", "utf-8")
137+
out_file = open(file_path, mode="w+", encoding="utf-8")
138138
out_file.writelines("\r\n".join(data))
139139
out_file.close()
140140
new_plans += 1
@@ -182,7 +182,7 @@ def view_summary_of_existing_case_plans(root, tests):
182182
else:
183183
case_path = os.path.join(folder_path, "case_plans", case_id)
184184
if os.path.exists(case_path):
185-
f = open(case_path, "r")
185+
f = open(case_path, mode="r")
186186
case_data = f.read()
187187
f.close()
188188
case_data_storage.append(case_data)
@@ -315,7 +315,7 @@ def view_summary_of_existing_case_plans(root, tests):
315315
full_plan = plan_head
316316

317317
file_path = "case_summary.md"
318-
file = open(file_path, "w+", "utf-8")
318+
file = open(file_path, mode="w+", encoding="utf-8")
319319
file.writelines("\r\n".join(full_plan))
320320
file.close()
321321

0 commit comments

Comments
 (0)