Merge pull request #2538 from seleniumbase/refresh-dependencies-and-examples

Refresh dependencies and examples
This commit is contained in:
Michael Mintz 2024-02-26 12:03:22 -05:00 committed by GitHub
commit 5d9fdc0ba0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 73 additions and 94 deletions

View File

@ -11,7 +11,7 @@ class GoogleTests(BaseCase):
def test_google_dot_com(self): def test_google_dot_com(self):
if self.headless and self._multithreaded: if self.headless and self._multithreaded:
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
print("Skipping test in headless multi-threaded mode.") print("\n Skipping test in headless multi-threaded mode.")
self.skip("Skipping test in headless multi-threaded mode.") self.skip("Skipping test in headless multi-threaded mode.")
self.open("https://google.com/ncr") self.open("https://google.com/ncr")
self.assert_title_contains("Google") self.assert_title_contains("Google")

View File

@ -36,7 +36,7 @@ class MyTests(BaseCase):
def test_page_objects(self): def test_page_objects(self):
if self.headless and self._multithreaded: if self.headless and self._multithreaded:
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
print("Skipping test in headless multi-threaded mode.") print("\n Skipping test in headless multi-threaded mode.")
self.skip("Skipping test in headless multi-threaded mode.") self.skip("Skipping test in headless multi-threaded mode.")
search_term = "SeleniumBase.io Docs" search_term = "SeleniumBase.io Docs"
expected_text = "SeleniumBase" expected_text = "SeleniumBase"

View File

@ -6,9 +6,8 @@ class GitHubTests(BaseCase):
def test_github(self): def test_github(self):
if self.headless or self.page_load_strategy == "none": if self.headless or self.page_load_strategy == "none":
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
message = "Unsupported mode for this test." print("\n Unsupported mode for this test.")
print("\n " + message) self.skip("Unsupported mode for this test.")
self.skip(message)
self.open("https://github.com/seleniumbase/SeleniumBase") self.open("https://github.com/seleniumbase/SeleniumBase")
self.click_if_visible('[data-action="click:signup-prompt#dismiss"]') self.click_if_visible('[data-action="click:signup-prompt#dismiss"]')
self.highlight("div.Layout-main") self.highlight("div.Layout-main")

View File

@ -5,18 +5,10 @@ BaseCase.main(__name__, __file__)
class ProxyTests(BaseCase): class ProxyTests(BaseCase):
def test_proxy(self): def test_proxy(self):
if self.headless: if self.headless or self.recorder_mode or self.browser == "safari":
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
print("Skipping test in Headless Mode.") print("\n Unsupported mode for this test.")
self.skip("Skipping test in Headless Mode.") self.skip("Unsupported mode for this test.")
elif self.recorder_mode:
self.open_if_not_url("about:blank")
print("Skipping test in Recorder Mode.")
self.skip("Skipping test in Recorder Mode.")
elif self.browser == "safari":
self.open_if_not_url("about:blank")
print("Skipping test for using Safari.")
self.skip("Skipping test for using Safari.")
settings.SKIP_JS_WAITS = True settings.SKIP_JS_WAITS = True
if not self.page_load_strategy == "none" and not self.undetectable: if not self.page_load_strategy == "none" and not self.undetectable:
# This page takes too long to load otherwise # This page takes too long to load otherwise

View File

@ -10,14 +10,10 @@ class RateLimitingTests(BaseCase):
print(item) print(item)
def test_rate_limited_printing(self): def test_rate_limited_printing(self):
if self._multithreaded: if self._multithreaded or self.recorder_mode:
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
print("Skipping test in multi-threaded mode.") print("\n Unsupported mode for this test.")
self.skip("Skipping test in multi-threaded mode.") self.skip("Unsupported mode for this test.")
if self.recorder_mode:
self.open_if_not_url("about:blank")
print("Skipping test in Recorder Mode.")
self.skip("Skipping test in Recorder Mode.")
message = "Running rate-limited print() on the command line" message = "Running rate-limited print() on the command line"
self.open("data:text/html,<p>%s</p>" % message) self.open("data:text/html,<p>%s</p>" % message)
print("\n%s:" % message) print("\n%s:" % message)

View File

@ -6,16 +6,10 @@ BaseCase.main(__name__, __file__)
class ShadowRootTest(BaseCase): class ShadowRootTest(BaseCase):
def test_shadow_root(self): def test_shadow_root(self):
if self.recorder_mode: if self.recorder_mode or not self.is_chromium():
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
message = "Skipping test in Recorder Mode." print("\n Unsupported mode for this test.")
print(message) self.skip("Unsupported mode for this test.")
self.skip(message)
elif not self.is_chromium():
self.open_if_not_url("about:blank")
message = "This test is only for Chromium browsers!"
print(message)
self.skip(message)
self.open("https://seleniumbase.io/other/shadow_dom") self.open("https://seleniumbase.io/other/shadow_dom")
print("") print("")
self.click("button.tab_1") self.click("button.tab_1")

View File

@ -8,20 +8,14 @@ class AppleTests(BaseCase):
self.demo_mode = True self.demo_mode = True
self.demo_sleep = 0.5 self.demo_sleep = 0.5
self.message_duration = 2.0 self.message_duration = 2.0
if self.is_chromium() and not self.disable_csp:
self.get_new_driver(browser=self.browser, disable_csp=True)
if self.headless: if self.headless:
if self._multithreaded: if self._multithreaded or self.undetectable or self.recorder_mode:
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
print("Skipping test in headless multi-threaded mode.") print("\n Unsupported mode for this test.")
self.skip("Skipping test in headless multi-threaded mode.") self.skip("Unsupported mode for this test.")
elif self.undetectable: elif self.is_chromium():
self.open_if_not_url("about:blank")
print("Skipping test in headless undetectable mode.")
self.skip("Skipping test in headless undetectable mode.")
elif self.recorder_mode:
self.open_if_not_url("about:blank")
print("Skipping test in headless Recorder Mode.")
self.skip("Skipping test in headless Recorder Mode.")
elif self.browser == "chrome" or self.browser == "edge":
self.get_new_driver(browser=self.browser, headless2=True) self.get_new_driver(browser=self.browser, headless2=True)
self.open("https://developer.apple.com/search/") self.open("https://developer.apple.com/search/")
title = "Testing with WebDriver in Safari" title = "Testing with WebDriver in Safari"

View File

@ -37,7 +37,7 @@ class CanvasTests(BaseCase):
self.open("https://seleniumbase.io/canvas/") self.open("https://seleniumbase.io/canvas/")
if self.undetectable: if self.undetectable:
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
print("Skip this test in undetectable mode.") print("\n Skip this test in undetectable mode.")
self.skip("Skip this test in undetectable mode.") self.skip("Skip this test in undetectable mode.")
self.assert_title_contains("Canvas") self.assert_title_contains("Canvas")
self.highlight("canvas") self.highlight("canvas")

View File

@ -8,10 +8,9 @@ BaseCase.main(__name__, __file__)
class ChromedriverTests(BaseCase): class ChromedriverTests(BaseCase):
def test_chromedriver_matches_chrome(self): def test_chromedriver_matches_chrome(self):
self.open("about:blank")
if self.browser != "chrome": if self.browser != "chrome":
self.open_if_not_url("data:,")
print("\n This test is only for Chrome!") print("\n This test is only for Chrome!")
print(' (Run with: "--browser=chrome")')
self.skip("This test is only for Chrome!") self.skip("This test is only for Chrome!")
chrome_version = self.get_chrome_version() chrome_version = self.get_chrome_version()
major_chrome_version = chrome_version.split(".")[0] major_chrome_version = chrome_version.split(".")[0]

View File

@ -10,8 +10,8 @@ class HackingTests(BaseCase):
def test_hack_search(self): def test_hack_search(self):
if self.headless: if self.headless:
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
print("\n This test is not for Headless Mode.") print("\n Skipping test in headless mode.")
self.skip('Do not use "--headless" with this test.') self.skip('Skipping test in headless mode.')
self.open("https://google.com/ncr") self.open("https://google.com/ncr")
self.hide_elements("iframe") self.hide_elements("iframe")
self.assert_element('[title="Search"]') self.assert_element('[title="Search"]')

View File

@ -6,9 +6,8 @@ class MultipleDriversTest(BaseCase):
def test_multiple_drivers(self): def test_multiple_drivers(self):
if self.browser == "safari": if self.browser == "safari":
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
message = "Safari doesn't support multiple drivers." print("\n Safari doesn't support multiple drivers.")
print(message) self.skip("Safari doesn't support multiple drivers.")
self.skip(message)
self.open("data:text/html,<h1>Driver 1</h1>") self.open("data:text/html,<h1>Driver 1</h1>")
driver2 = self.get_new_driver() driver2 = self.get_new_driver()
self.open("data:text/html,<h1>Driver 2</h1>") self.open("data:text/html,<h1>Driver 2</h1>")

View File

@ -7,7 +7,6 @@ class OverrideDriverTest(BaseCase):
def get_new_driver(self, *args, **kwargs): def get_new_driver(self, *args, **kwargs):
"""This method overrides get_new_driver() from BaseCase.""" """This method overrides get_new_driver() from BaseCase."""
options = webdriver.ChromeOptions() options = webdriver.ChromeOptions()
options.add_argument("--disable-3d-apis")
options.add_argument("--disable-notifications") options.add_argument("--disable-notifications")
if self.headless: if self.headless:
options.add_argument("--headless=new") options.add_argument("--headless=new")
@ -24,4 +23,9 @@ class OverrideDriverTest(BaseCase):
def test_driver_override(self): def test_driver_override(self):
self.open("https://seleniumbase.io/demo_page") self.open("https://seleniumbase.io/demo_page")
self.assert_text("Demo Page", "h1") self.type("#myTextInput", "This is Automated")
self.set_value("input#mySlider", "100")
self.select_option_by_text("#mySelect", "Set to 100%")
self.click("#checkBox1")
self.drag_and_drop("img#logo", "div#drop2")
self.click('button:contains("Click Me")')

View File

@ -13,12 +13,18 @@ def sb(request):
def get_new_driver(self, *args, **kwargs): def get_new_driver(self, *args, **kwargs):
"""This method overrides get_new_driver() from BaseCase.""" """This method overrides get_new_driver() from BaseCase."""
options = webdriver.ChromeOptions() options = webdriver.ChromeOptions()
options.add_argument("--disable-notifications")
if self.headless: if self.headless:
options.add_argument("--headless=new") options.add_argument("--headless=new")
options.add_argument("--disable-gpu") options.add_argument("--disable-gpu")
options.add_experimental_option( options.add_experimental_option(
"excludeSwitches", ["enable-automation"], "excludeSwitches", ["enable-automation", "enable-logging"],
) )
prefs = {
"credentials_enable_service": False,
"profile.password_manager_enabled": False,
}
options.add_experimental_option("prefs", prefs)
return webdriver.Chrome(options=options) return webdriver.Chrome(options=options)
def setUp(self): def setUp(self):
@ -63,9 +69,19 @@ def sb(request):
def test_override_fixture_no_class(sb): def test_override_fixture_no_class(sb):
sb.open("https://seleniumbase.io/demo_page") sb.open("https://seleniumbase.io/demo_page")
sb.type("#myTextInput", "This is Automated") sb.type("#myTextInput", "This is Automated")
sb.set_value("input#mySlider", "100")
sb.select_option_by_text("#mySelect", "Set to 100%")
sb.click("#checkBox1")
sb.drag_and_drop("img#logo", "div#drop2")
sb.click('button:contains("Click Me")')
class TestOverride: class TestOverride:
def test_override_fixture_inside_class(self, sb): def test_override_fixture_inside_class(self, sb):
sb.open("https://seleniumbase.io/demo_page") sb.open("https://seleniumbase.io/demo_page")
sb.type("#myTextInput", "This is Automated") sb.type("#myTextInput", "This is Automated")
sb.set_value("input#mySlider", "100")
sb.select_option_by_text("#mySelect", "Set to 100%")
sb.click("#checkBox1")
sb.drag_and_drop("img#logo", "div#drop2")
sb.click('button:contains("Click Me")')

View File

@ -19,18 +19,10 @@ class ShadowDomTests(BaseCase):
return tar_file return tar_file
def test_shadow_dom(self): def test_shadow_dom(self):
if self.browser != "chrome": if not self.browser == "chrome" or self.headless or self.recorder_mode:
self.open("about:blank") self.open_if_not_url("about:blank")
print("\n This test is for Google Chrome only!") print("\n Unsupported mode for this test.")
self.skip("This test is for Google Chrome only!") self.skip("Unsupported mode for this test.")
if self.headless:
self.open("about:blank")
print("\n This test doesn't run in headless mode!")
self.skip("This test doesn't run in headless mode!")
if self.recorder_mode:
self.open("about:blank")
print("Skipping test in Recorder Mode.")
self.skip("Skipping test in Recorder Mode.")
# Download Python package files from PyPI # Download Python package files from PyPI
file_name_1 = self.download_tar_file_from_pypi("sbase") file_name_1 = self.download_tar_file_from_pypi("sbase")

View File

@ -5,11 +5,9 @@ BaseCase.main(__name__, __file__)
class ChromedriverTests(BaseCase): class ChromedriverTests(BaseCase):
def test_fail_if_versions_dont_match(self): def test_fail_if_versions_dont_match(self):
self.open("data:,") self.open("about:blank")
if self.browser != "chrome": if self.browser != "chrome":
self.open_if_not_url("data:,")
print("\n This test is only for Chrome!") print("\n This test is only for Chrome!")
print(" (Run with: '--chrome')")
self.skip("This test is only for Chrome!") self.skip("This test is only for Chrome!")
chrome_version = self.get_chrome_version() chrome_version = self.get_chrome_version()
major_chrome_version = chrome_version.split(".")[0] major_chrome_version = chrome_version.split(".")[0]

View File

@ -5,23 +5,19 @@ BaseCase.main(__name__, __file__)
class YouTubeSearchTests(BaseCase): class YouTubeSearchTests(BaseCase):
def test_youtube_autocomplete_results(self): def test_youtube_autocomplete_results(self):
"""Verify YouTube autocomplete search results.""" """Verify YouTube autocomplete search results."""
if self.headless: if self.headless or self.browser == "safari":
self.open_if_not_url("about:blank") self.open_if_not_url("about:blank")
message = "This test is skipped in headless mode." print("\n Unsupported mode for this test.")
print(message) self.skip("Unsupported mode for this test.")
self.skip(message)
elif self.browser == "safari":
self.open_if_not_url("about:blank")
message = "This test is skipped when using Safari."
print(message)
self.skip(message)
self.open("https://www.youtube.com/c/MichaelMintz") self.open("https://www.youtube.com/c/MichaelMintz")
search_term = "seleniumbase" search_term = "seleniumbase"
search_selector = "input#search" search_selector = "input#search"
result_selector = 'li[role="presentation"]' result_selector = 'li[role="presentation"]'
self.click_if_visible('button[aria-label="Close"]') self.click_if_visible('button[aria-label="Close"]')
self.double_click(search_selector) self.double_click(search_selector)
self.sleep(0.15)
self.type(search_selector, search_term) self.type(search_selector, search_term)
self.sleep(0.15)
# First verify that an autocomplete result exists # First verify that an autocomplete result exists
self.assert_element(result_selector) self.assert_element(result_selector)
top_result = self.get_text(result_selector) top_result = self.get_text(result_selector)

View File

@ -3,10 +3,10 @@
regex>=2023.12.25 regex>=2023.12.25
pymdown-extensions>=10.7 pymdown-extensions>=10.7
pipdeptree>=2.14.0 pipdeptree>=2.15.1
python-dateutil>=2.8.2 python-dateutil>=2.8.2
Markdown==3.5.2 Markdown==3.5.2
markdown2==2.4.12 markdown2==2.4.13
MarkupSafe==2.1.5 MarkupSafe==2.1.5
Jinja2==3.1.3 Jinja2==3.1.3
click==8.1.7 click==8.1.7
@ -20,7 +20,7 @@ lxml==5.1.0
pyquery==2.0.0 pyquery==2.0.0
readtime==3.0.0 readtime==3.0.0
mkdocs==1.5.3 mkdocs==1.5.3
mkdocs-material==9.5.10 mkdocs-material==9.5.11
mkdocs-exclude-search==0.6.6 mkdocs-exclude-search==0.6.6
mkdocs-simple-hooks==0.1.5 mkdocs-simple-hooks==0.1.5
mkdocs-material-extensions==1.3.1 mkdocs-material-extensions==1.3.1

View File

@ -1,7 +1,7 @@
pip>=24.0 pip>=24.0
packaging>=23.2 packaging>=23.2
setuptools>=68.0.0;python_version<"3.8" setuptools>=68.0.0;python_version<"3.8"
setuptools>=69.1.0;python_version>="3.8" setuptools>=69.1.1;python_version>="3.8"
wheel>=0.42.0 wheel>=0.42.0
attrs>=23.2.0 attrs>=23.2.0
certifi>=2024.2.2 certifi>=2024.2.2
@ -9,7 +9,7 @@ filelock>=3.12.2;python_version<"3.8"
filelock>=3.13.1;python_version>="3.8" filelock>=3.13.1;python_version>="3.8"
platformdirs>=4.0.0;python_version<"3.8" platformdirs>=4.0.0;python_version<"3.8"
platformdirs>=4.2.0;python_version>="3.8" platformdirs>=4.2.0;python_version>="3.8"
typing-extensions>=4.9.0;python_version>="3.8" typing-extensions>=4.10.0;python_version>="3.8"
parse>=1.20.1 parse>=1.20.1
parse-type>=0.6.2 parse-type>=0.6.2
pyyaml>=6.0.1 pyyaml>=6.0.1
@ -21,7 +21,7 @@ urllib3>=1.26.18,<2;python_version<"3.10"
urllib3>=1.26.18,<2.3.0;python_version>="3.10" urllib3>=1.26.18,<2.3.0;python_version>="3.10"
requests==2.31.0 requests==2.31.0
pynose==1.5.0 pynose==1.5.0
sniffio==1.3.0 sniffio==1.3.1
h11==0.14.0 h11==0.14.0
outcome==1.3.0.post0 outcome==1.3.0.post0
trio==0.22.2;python_version<"3.8" trio==0.22.2;python_version<"3.8"
@ -39,7 +39,7 @@ pluggy==1.2.0;python_version<"3.8"
pluggy==1.4.0;python_version>="3.8" pluggy==1.4.0;python_version>="3.8"
py==1.11.0 py==1.11.0
pytest==7.4.4;python_version<"3.8" pytest==7.4.4;python_version<"3.8"
pytest==8.0.1;python_version>="3.8" pytest==8.0.2;python_version>="3.8"
pytest-html==2.0.1 pytest-html==2.0.1
pytest-metadata==3.0.0;python_version<"3.8" pytest-metadata==3.0.0;python_version<"3.8"
pytest-metadata==3.1.1;python_version>="3.8" pytest-metadata==3.1.1;python_version>="3.8"
@ -69,7 +69,7 @@ rich==13.7.0
coverage==6.2;python_version<"3.7" coverage==6.2;python_version<"3.7"
coverage==7.2.7;python_version>="3.7" and python_version<"3.8" coverage==7.2.7;python_version>="3.7" and python_version<"3.8"
coverage==7.4.2;python_version>="3.8" coverage==7.4.3;python_version>="3.8"
pytest-cov==4.0.0;python_version<"3.7" pytest-cov==4.0.0;python_version<"3.7"
pytest-cov==4.1.0;python_version>="3.7" pytest-cov==4.1.0;python_version>="3.7"
flake8==5.0.4;python_version<"3.9" flake8==5.0.4;python_version<"3.9"

View File

@ -1,2 +1,2 @@
# seleniumbase package # seleniumbase package
__version__ = "4.24.0" __version__ = "4.24.1"

View File

@ -149,7 +149,7 @@ setup(
'pip>=24.0', 'pip>=24.0',
'packaging>=23.2', 'packaging>=23.2',
'setuptools>=68.0.0;python_version<"3.8"', 'setuptools>=68.0.0;python_version<"3.8"',
'setuptools>=69.1.0;python_version>="3.8"', 'setuptools>=69.1.1;python_version>="3.8"',
'wheel>=0.42.0', 'wheel>=0.42.0',
'attrs>=23.2.0', 'attrs>=23.2.0',
"certifi>=2024.2.2", "certifi>=2024.2.2",
@ -157,7 +157,7 @@ setup(
'filelock>=3.13.1;python_version>="3.8"', 'filelock>=3.13.1;python_version>="3.8"',
'platformdirs>=4.0.0;python_version<"3.8"', 'platformdirs>=4.0.0;python_version<"3.8"',
'platformdirs>=4.2.0;python_version>="3.8"', 'platformdirs>=4.2.0;python_version>="3.8"',
'typing-extensions>=4.9.0;python_version>="3.8"', 'typing-extensions>=4.10.0;python_version>="3.8"',
'parse>=1.20.1', 'parse>=1.20.1',
'parse-type>=0.6.2', 'parse-type>=0.6.2',
'pyyaml>=6.0.1', 'pyyaml>=6.0.1',
@ -169,7 +169,7 @@ setup(
'urllib3>=1.26.18,<2.3.0;python_version>="3.10"', 'urllib3>=1.26.18,<2.3.0;python_version>="3.10"',
'requests==2.31.0', 'requests==2.31.0',
"pynose==1.5.0", "pynose==1.5.0",
'sniffio==1.3.0', 'sniffio==1.3.1',
'h11==0.14.0', 'h11==0.14.0',
'outcome==1.3.0.post0', 'outcome==1.3.0.post0',
'trio==0.22.2;python_version<"3.8"', 'trio==0.22.2;python_version<"3.8"',
@ -187,7 +187,7 @@ setup(
'pluggy==1.4.0;python_version>="3.8"', 'pluggy==1.4.0;python_version>="3.8"',
"py==1.11.0", "py==1.11.0",
'pytest==7.4.4;python_version<"3.8"', 'pytest==7.4.4;python_version<"3.8"',
'pytest==8.0.1;python_version>="3.8"', 'pytest==8.0.2;python_version>="3.8"',
"pytest-html==2.0.1", # Newer ones had issues "pytest-html==2.0.1", # Newer ones had issues
'pytest-metadata==3.0.0;python_version<"3.8"', 'pytest-metadata==3.0.0;python_version<"3.8"',
'pytest-metadata==3.1.1;python_version>="3.8"', 'pytest-metadata==3.1.1;python_version>="3.8"',
@ -225,7 +225,7 @@ setup(
# Usage: coverage run -m pytest; coverage html; coverage report # Usage: coverage run -m pytest; coverage html; coverage report
"coverage": [ "coverage": [
'coverage==7.2.7;python_version<"3.8"', 'coverage==7.2.7;python_version<"3.8"',
'coverage==7.4.2;python_version>="3.8"', 'coverage==7.4.3;python_version>="3.8"',
'pytest-cov==4.1.0', 'pytest-cov==4.1.0',
], ],
# pip install -e .[flake8] # pip install -e .[flake8]
@ -251,7 +251,7 @@ setup(
'pdfminer.six==20221105;python_version<"3.8"', 'pdfminer.six==20221105;python_version<"3.8"',
'pdfminer.six==20231228;python_version>="3.8"', 'pdfminer.six==20231228;python_version>="3.8"',
'cryptography==39.0.2;python_version<"3.9"', 'cryptography==39.0.2;python_version<"3.9"',
'cryptography==42.0.4;python_version>="3.9"', 'cryptography==42.0.5;python_version>="3.9"',
'cffi==1.15.1;python_version<"3.8"', 'cffi==1.15.1;python_version<"3.8"',
'cffi==1.16.0;python_version>="3.8"', 'cffi==1.16.0;python_version>="3.8"',
"pycparser==2.21", "pycparser==2.21",