Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/boilerplates/samples/test_page_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ def do_search_and_click(self, sb, search_term):

class MyTests(BaseCase):
def test_page_objects(self):
if self.headless and self._multithreaded:
if self.headless:
self.open_if_not_url("about:blank")
print("\n Skipping test in headless multi-threaded mode.")
self.skip("Skipping test in headless multi-threaded mode.")
print("\n Skipping test in headless mode.")
self.skip("Skipping test in headless mode.")
if not self.undetectable:
self.get_new_driver(undetectable=True)
search_term = "SeleniumBase.io Docs"
expected_text = "SeleniumBase"
GooglePage().go_to_google(self)
Expand Down
3 changes: 2 additions & 1 deletion examples/cdp_mode/raw_cdp_turnstile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
sb = sb_cdp.Chrome(url)
sb.gui_click_captcha()
sb.assert_element("img#captcha-success")
sb.sleep(2)
sb.set_messenger_theme(location="top_left")
sb.post_message("SeleniumBase wasn't detected", duration=3)
sb.driver.stop()
11 changes: 6 additions & 5 deletions examples/test_hack_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ def test_hack_search(self):
self.open_if_not_url("about:blank")
print("\n Skipping test in headless mode.")
self.skip('Skipping test in headless mode.')
if not self.undetectable:
self.get_new_driver(undetectable=True)
self.open("https://google.com/ncr")
self.hide_elements("iframe")
self.assert_element('[title="Search"]')
self.sleep(0.5)
self.set_attribute('[action="/search"]', "action", "//bing.com/search")
self.set_attributes('[value="Google Search"]', "value", "Bing Search")
self.type('[title="Search"]', "GitHub SeleniumBase Docs Install")
self.type('[title="Search"]', "SeleniumBase GitHub Page URL")
self.sleep(0.5)
self.js_click('[value="Bing Search"]')
self.highlight("h1.b_logo", loops=8)
self.highlight_click('[href*="github.com/seleniumbase/SeleniumBase"]')
self.highlight_click('[href="/seleniumbase/SeleniumBase"]')
self.assert_text("SeleniumBase", "strong a")
self.highlight("strong a")
source = self.get_page_source()
self.assert_true("github.com/seleniumbase/SeleniumBase" in source)
self.click('a:contains("seleniumbase/SeleniumBase")')
self.js_click('a[title="examples"]')
self.highlight('#repo-content-turbo-frame')
self.js_click('a[title="test_hack_search.py"]')
Expand Down
6 changes: 3 additions & 3 deletions help_docs/how_it_works.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

👁️🔎 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.
👁️🔎 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).

👁️🔎 ``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``.

Expand Down Expand Up @@ -50,7 +50,7 @@ BaseCase.main(__name__, __file__)

class TestSimpleLogin(BaseCase):
def test_simple_login(self):
self.open("https://seleniumbase.io/simple/login")
self.open("seleniumbase.io/simple/login")
self.type("#username", "demo_user")
self.type("#password", "secret_pass")
self.click('a:contains("Sign in")')
Expand Down Expand Up @@ -80,7 +80,7 @@ from seleniumbase import Driver

driver = Driver()
try:
driver.get("https://seleniumbase.io/simple/login")
driver.open("seleniumbase.io/simple/login")
driver.type("#username", "demo_user")
driver.type("#password", "secret_pass")
driver.click('a:contains("Sign in")')
Expand Down
1 change: 0 additions & 1 deletion help_docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pip install git+https://github.com/seleniumbase/SeleniumBase.git@master#egg=sele

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

(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.)

Expand Down
4 changes: 2 additions & 2 deletions mkdocs_build/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def main(*args, **kwargs):

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

Expand Down Expand Up @@ -195,6 +195,6 @@ def main(*args, **kwargs):
)
seleniumbase_lines.append(line)
if changed:
out_file = open(readme_file, "w+", encoding="utf-8")
out_file = open(readme_file, mode="w+", encoding="utf-8")
out_file.writelines("\r\n".join(seleniumbase_lines))
out_file.close()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pyyaml>=6.0.3
pygments>=2.19.2
pyreadline3>=3.5.4;platform_system=="Windows"
tabcompleter>=1.4.0
pdbp>=1.7.1
pdbp>=1.8.0
idna>=3.11
chardet==5.2.0
charset-normalizer>=3.4.4,<4
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.43.1"
__version__ = "4.43.2"
14 changes: 7 additions & 7 deletions seleniumbase/behave/behave_sb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,24 +1216,24 @@ def _create_dashboard_assets_():
add_pytest_style_css = True
if os.path.exists(pytest_style_css):
existing_pytest_style = None
with open(pytest_style_css, "r") as f:
with open(pytest_style_css, mode="r") as f:
existing_pytest_style = f.read()
if existing_pytest_style == get_pytest_style():
add_pytest_style_css = False
if add_pytest_style_css:
out_file = open(pytest_style_css, "w+", encoding="utf-8")
out_file = open(pytest_style_css, mode="w+", encoding="utf-8")
out_file.writelines(get_pytest_style())
out_file.close()
live_js_file = os.path.join(assets_folder, "live.js")
add_live_js_file = True
if os.path.exists(live_js_file):
existing_live_js = None
with open(live_js_file, "r") as f:
with open(live_js_file, mode="r") as f:
existing_live_js = f.read()
if existing_live_js == live_js:
add_live_js_file = False
if add_live_js_file:
out_file = open(live_js_file, "w+", encoding="utf-8")
out_file = open(live_js_file, mode="w+", encoding="utf-8")
out_file.writelines(live_js)
out_file.close()

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

with open(pie_path, "r") as f:
with open(pie_path, mode="r") as f:
dash_pie = f.read().strip()
sb_config._saved_dashboard_pie = json.loads(dash_pie)
# If the test run doesn't complete by itself, stop refresh
Expand All @@ -1326,7 +1326,7 @@ def _perform_behave_unconfigure_():
the_html_d = the_html_d.replace(find_it_3, swap_with_3)
the_html_d = the_html_d.replace(find_it_4, swap_with_4)
the_html_d += stamp
with open(dashboard_path, "w", encoding="utf-8") as f:
with open(dashboard_path, mode="w", encoding="utf-8") as f:
f.write(the_html_d) # Finalize the dashboard
except KeyboardInterrupt:
pass
Expand Down
6 changes: 3 additions & 3 deletions seleniumbase/console_scripts/sb_caseplans.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def generate_case_plan_boilerplates(
file_name = case_id
file_path = os.path.join(full_folder_path, file_name)
if not os.path.exists(file_path):
out_file = open(file_path, "w+", "utf-8")
out_file = open(file_path, mode="w+", encoding="utf-8")
out_file.writelines("\r\n".join(data))
out_file.close()
new_plans += 1
Expand Down Expand Up @@ -182,7 +182,7 @@ def view_summary_of_existing_case_plans(root, tests):
else:
case_path = os.path.join(folder_path, "case_plans", case_id)
if os.path.exists(case_path):
f = open(case_path, "r")
f = open(case_path, mode="r")
case_data = f.read()
f.close()
case_data_storage.append(case_data)
Expand Down Expand Up @@ -315,7 +315,7 @@ def view_summary_of_existing_case_plans(root, tests):
full_plan = plan_head

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

Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/console_scripts/sb_mkchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def main():
continue
new_data.append(line)
data = new_data
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()
if " " not in file_name:
Expand Down
42 changes: 21 additions & 21 deletions seleniumbase/console_scripts/sb_mkdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def main():
data.append(seleniumbase_req)
data.append("")
file_path = "%s/%s" % (dir_name, "requirements.txt")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand Down Expand Up @@ -151,7 +151,7 @@ def main():
data.append(" production: custom marker")
data.append("")
file_path = "%s/%s" % (dir_name, "pytest.ini")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -168,14 +168,14 @@ def main():
data.append("show_skipped=false")
data.append("show_timings=false")
file_path = "%s/%s" % (dir_name, "setup.cfg")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

data = []
data.append("")
file_path = "%s/%s" % (dir_name, "__init__.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand Down Expand Up @@ -311,7 +311,7 @@ def main():
data.append("temp_*/")
data.append("node_modules")
file_path = "%s/%s" % (dir_name, ".gitignore")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -323,7 +323,7 @@ def main():
data.append(" ├── requirements.txt")
data.append(" └── setup.cfg")
file_path = "%s/%s" % (dir_name, "outline.rst")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()
os.system("sbase print %s -n" % file_path)
Expand Down Expand Up @@ -367,7 +367,7 @@ def main():
data.append(' self.assert_element("div#login_button_container")')
data.append("")
file_path = "%s/%s" % (dir_name, "my_first_test.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand Down Expand Up @@ -460,7 +460,7 @@ def main():
data.append(' self.assert_text("SeleniumBase", "h2")')
data.append("")
file_path = "%s/%s" % (dir_name, "test_demo_site.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand Down Expand Up @@ -499,7 +499,7 @@ def main():
data.append(' self.assert_title_contains(title_text)')
data.append("")
file_path = "%s/%s" % (dir_name, "parameterized_test.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -509,7 +509,7 @@ def main():
data = []
data.append("")
file_path = "%s/%s" % (dir_name_2, "__init__.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand Down Expand Up @@ -544,7 +544,7 @@ def main():
data.append(" pass")
data.append("")
file_path = "%s/%s" % (dir_name_2, "base_test_case.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -553,7 +553,7 @@ def main():
data.append(' html = "html"')
data.append("")
file_path = "%s/%s" % (dir_name_2, "page_objects.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -569,7 +569,7 @@ def main():
data.append(" self.assert_element(Page.html)")
data.append("")
file_path = "%s/%s" % (dir_name_2, "boilerplate_test.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -593,7 +593,7 @@ def main():
data.append(' DataPage().add_input_text(self, "Goodbye!")')
data.append("")
file_path = "%s/%s" % (dir_name_2, "classic_obj_test.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -613,7 +613,7 @@ def main():
data.append(' DataPage().add_input_text(sb, "Goodbye!")')
data.append("")
file_path = "%s/%s" % (dir_name_2, "sb_fixture_test.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -623,7 +623,7 @@ def main():
data = []
data.append("")
file_path = "%s/%s" % (dir_name_3, "__init__.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand Down Expand Up @@ -651,7 +651,7 @@ def main():
)
data.append("")
file_path = "%s/%s" % (dir_name_3, "google_test.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -669,7 +669,7 @@ def main():
data.append(' search_results = "div#center_col"')
data.append("")
file_path = "%s/%s" % (dir_name_3, "google_objects.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand Down Expand Up @@ -701,7 +701,7 @@ def main():
data.append(' self.assert_element("div#login_button_container")')
data.append("")
file_path = "%s/%s" % (dir_name_3, "swag_labs_test.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -728,7 +728,7 @@ def main():
data.append(' sb.assert_element("div#login_button_container")')
data.append("")
file_path = "%s/%s" % (dir_name_3, "sb_swag_test.py")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()

Expand All @@ -755,7 +755,7 @@ def main():
data.append(" ├── sb_swag_test.py")
data.append(" └── swag_labs_test.py")
file_path = "%s/%s" % (dir_name, "outline.rst")
file = open(file_path, "w+", "utf-8")
file = open(file_path, mode="w+", encoding="utf-8")
file.writelines("\r\n".join(data))
file.close()
if " " not in file_path:
Expand Down
Loading