Refactor examples

This commit is contained in:
Michael Mintz 2022-04-13 13:40:01 -04:00
parent 5a151bfe85
commit 01669c9b16
27 changed files with 105 additions and 108 deletions

View File

@ -55,7 +55,7 @@ class DialogBoxTests(BaseCase):
options = [("theme", "bootstrap"), ("width", "52%")]
message = 'If the lowercase button text is "yes" or "no", '
message += '<br><br>you can use the "Y" or "N" keys as shortcuts. '
message += '<br><br><br>Other shortcuts include: <br><br>'
message += "<br><br><br>Other shortcuts include: <br><br>"
message += '"1": 1st button, "2": 2nd button, etc. Got it?'
buttons = [("YES", "green"), ("NO", "red")]
choice = self.get_jqc_button_input(message, buttons, options)

View File

@ -14,7 +14,7 @@ class GitHubTests(BaseCase):
self.get_new_driver(
agent="""Mozilla/5.0 """
"""AppleWebKit/537.36 (KHTML, like Gecko) """
"""Chrome/Version 96.0.4664.55 Safari/537.36"""
"""Chrome/Version 100.0.4896.88 Safari/537.36"""
)
self.open("https://github.com/search?q=SeleniumBase")
self.slow_click('a[href="/seleniumbase/SeleniumBase"]')

View File

@ -24,32 +24,32 @@ class HackTests(BaseCase):
self.click_if_visible('button[aria-label="Close"]')
self.set_text_content("h1#firstHeading", aybabtu)
self.set_text_content("#ca-history a", aybabtu)
self.set_text_content('#n-mainpage-description a', "ALL")
self.set_text_content('#n-contents a', "YOUR")
self.set_text_content('#n-currentevents a', "BASE")
self.set_text_content('#n-randompage a', "ARE")
self.set_text_content('#n-aboutsite a', "BELONG")
self.set_text_content('#n-contactpage a', "TO")
self.set_text_content('#n-sitesupport a', "US")
self.set_text_content('.tocsection-1 span.toctext', "ALL")
self.set_text_content('.tocsection-2 span.toctext', "YOUR")
self.set_text_content('.tocsection-3 span.toctext', "BASE")
self.set_text_content('.tocsection-4 span.toctext', "ARE")
self.set_text_content('.tocsection-5 span.toctext', "BELONG")
self.set_text_content('.tocsection-6 span.toctext', "TO")
self.set_text_content('.tocsection-7 span.toctext', "US")
self.set_text_content("#n-mainpage-description a", "ALL")
self.set_text_content("#n-contents a", "YOUR")
self.set_text_content("#n-currentevents a", "BASE")
self.set_text_content("#n-randompage a", "ARE")
self.set_text_content("#n-aboutsite a", "BELONG")
self.set_text_content("#n-contactpage a", "TO")
self.set_text_content("#n-sitesupport a", "US")
self.set_text_content(".tocsection-1 span.toctext", "ALL")
self.set_text_content(".tocsection-2 span.toctext", "YOUR")
self.set_text_content(".tocsection-3 span.toctext", "BASE")
self.set_text_content(".tocsection-4 span.toctext", "ARE")
self.set_text_content(".tocsection-5 span.toctext", "BELONG")
self.set_text_content(".tocsection-6 span.toctext", "TO")
self.set_text_content(".tocsection-7 span.toctext", "US")
self.highlight("h1#firstHeading", loops=2, scroll=False)
self.highlight("#ca-history a", loops=2, scroll=False)
self.highlight("nav#p-navigation", loops=2, scroll=False)
self.highlight("div#toc", loops=2, scroll=False)
self.highlight('.tocsection-1 span.toctext', loops=1, scroll=False)
self.highlight('.tocsection-2 span.toctext', loops=1, scroll=False)
self.highlight('.tocsection-3 span.toctext', loops=2, scroll=False)
self.highlight('.tocsection-4 span.toctext', loops=1, scroll=False)
self.highlight('.tocsection-5 span.toctext', loops=1, scroll=False)
self.highlight('.tocsection-6 span.toctext', loops=1, scroll=False)
self.highlight('.tocsection-7 span.toctext', loops=2, scroll=False)
zoom_in = 'div.thumbinner{zoom: 1.4;-moz-transform: scale(1.4);}'
self.highlight(".tocsection-1 span.toctext", loops=1, scroll=False)
self.highlight(".tocsection-2 span.toctext", loops=1, scroll=False)
self.highlight(".tocsection-3 span.toctext", loops=2, scroll=False)
self.highlight(".tocsection-4 span.toctext", loops=1, scroll=False)
self.highlight(".tocsection-5 span.toctext", loops=1, scroll=False)
self.highlight(".tocsection-6 span.toctext", loops=1, scroll=False)
self.highlight(".tocsection-7 span.toctext", loops=2, scroll=False)
zoom_in = "div.thumbinner{zoom: 1.4;-moz-transform: scale(1.4);}"
self.add_css_style(zoom_in)
self.highlight("div.thumbinner", loops=8, scroll=False)
@ -82,7 +82,7 @@ class HackTests(BaseCase):
self.set_text_content('a[href*="google.com/img"]', abtu)
self.set_attributes('[value="Google Search"]', "value", ayb)
self.set_attributes('[value="I\'m Feeling Lucky"]', "value", abtu)
zoom_in = 'a{zoom: 1.2;-moz-transform: scale(1.2);}'
zoom_in = "a{zoom: 1.2;-moz-transform: scale(1.2);}"
self.add_css_style(zoom_in)
zoom_in = (
'[value="ALL YOUR BASE"]{zoom: 1.3;-moz-transform: scale(1.3);}'
@ -104,36 +104,36 @@ class HackTests(BaseCase):
self.highlight('a[href*="w/signup"]', loops=6, scroll=False)
self.open("https://www.youtube.com/")
self.set_text_content('%s(1)' % yt_chip, "ALL")
self.set_text_content('%s(2)' % yt_chip, "YOUR")
self.set_text_content('%s(3)' % yt_chip, "BASE")
self.set_text_content('%s(4)' % yt_chip, "ARE")
self.set_text_content('%s(5)' % yt_chip, "BELONG")
self.set_text_content('%s(6)' % yt_chip, "TO")
self.set_text_content('%s(7)' % yt_chip, "US")
self.set_text_content('%s(8)' % yt_chip, "!")
self.set_text_content('%s(9)' % yt_chip, "!")
self.set_text_content('%s(10)' % yt_chip, "!")
self.set_text_content("%s(1)" % yt_chip, "ALL")
self.set_text_content("%s(2)" % yt_chip, "YOUR")
self.set_text_content("%s(3)" % yt_chip, "BASE")
self.set_text_content("%s(4)" % yt_chip, "ARE")
self.set_text_content("%s(5)" % yt_chip, "BELONG")
self.set_text_content("%s(6)" % yt_chip, "TO")
self.set_text_content("%s(7)" % yt_chip, "US")
self.set_text_content("%s(8)" % yt_chip, "!")
self.set_text_content("%s(9)" % yt_chip, "!")
self.set_text_content("%s(10)" % yt_chip, "!")
self.click_if_visible("#dismiss-button")
self.click_if_visible('button[aria-label="Close"]')
self.highlight("#scroll-container", loops=5, scroll=False)
self.highlight('%s(1)' % yt_chip, loops=1, scroll=False)
self.highlight('%s(2)' % yt_chip, loops=1, scroll=False)
self.highlight('%s(3)' % yt_chip, loops=3, scroll=False)
self.highlight('%s(4)' % yt_chip, loops=1, scroll=False)
self.highlight('%s(5)' % yt_chip, loops=1, scroll=False)
self.highlight('%s(6)' % yt_chip, loops=1, scroll=False)
self.highlight('%s(7)' % yt_chip, loops=3, scroll=False)
self.highlight("%s(1)" % yt_chip, loops=1, scroll=False)
self.highlight("%s(2)" % yt_chip, loops=1, scroll=False)
self.highlight("%s(3)" % yt_chip, loops=3, scroll=False)
self.highlight("%s(4)" % yt_chip, loops=1, scroll=False)
self.highlight("%s(5)" % yt_chip, loops=1, scroll=False)
self.highlight("%s(6)" % yt_chip, loops=1, scroll=False)
self.highlight("%s(7)" % yt_chip, loops=3, scroll=False)
self.highlight("#scroll-container", loops=7, scroll=False)
self.open("https://github.com/features/actions")
self.set_text_content('a[href="/team"]', ayb)
self.set_text_content('a[href="/enterprise"]', abtu)
self.set_text_content('h1 span:nth-child(1)', ayb)
self.set_text_content('h1 span:nth-of-type(2)', "ARE")
self.set_text_content('h1 span:nth-of-type(3)', "BELONG")
self.set_text_content('h1 span:nth-of-type(4)', "TO")
self.set_text_content('h1 span:nth-of-type(5)', "US")
self.set_text_content("h1 span:nth-child(1)", ayb)
self.set_text_content("h1 span:nth-of-type(2)", "ARE")
self.set_text_content("h1 span:nth-of-type(3)", "BELONG")
self.set_text_content("h1 span:nth-of-type(4)", "TO")
self.set_text_content("h1 span:nth-of-type(5)", "US")
self.type('input[name="q"]', aybabtu.lower())
self.click("h1", scroll=False)
self.highlight("nav", loops=5, scroll=False)
@ -157,8 +157,8 @@ class HackTests(BaseCase):
self.set_text_content('aside a[class*="tful"]:nth-child(4)', aybabtu)
self.set_text_content('aside a[class*="tful"]:nth-child(5)', aybabtu)
self.set_attribute("a.crayons-avatar img", "src", sb_dashboard_logo)
self.set_text_content('.profile-preview-card button', "SeleniumBase")
self.set_text_content('h2.crayons-story__title a', aybabtu)
self.set_text_content(".profile-preview-card button", "SeleniumBase")
self.set_text_content("h2.crayons-story__title a", aybabtu)
self.type('input[name="q"]', aybabtu)
self.highlight('input[name="q"]', loops=4, scroll=False)
self.highlight('[aria-label="Primary sidebar"] div div', scroll=False)
@ -180,12 +180,12 @@ class HackTests(BaseCase):
self.highlight("h1", loops=6, scroll=False)
self.highlight('a[aria-label*="Try PlayF"]', loops=4, scroll=False)
self.highlight('a[aria-label*="Sign in to"]', loops=4, scroll=False)
self.highlight('button#live-engage-btn', loops=6, scroll=False)
self.highlight("button#live-engage-btn", loops=6, scroll=False)
self.open("https://www.snapchat.com/")
self.set_text_content("h1", ayb)
self.set_text_content("form .button-large span span", abtu)
zoom_in = 'a.button-large span{zoom: 1.2;-moz-transform: scale(1.2);}'
zoom_in = "a.button-large span{zoom: 1.2;-moz-transform: scale(1.2);}"
self.add_css_style(zoom_in)
self.highlight("h1", loops=6, scroll=False)
self.highlight("form .button-large span span", loops=8, scroll=False)
@ -201,7 +201,7 @@ class HackTests(BaseCase):
self.set_text_content('span:contains("Labs")', "US")
self.set_value("input#store_nav_search_term", ayb + " . . . .")
self.highlight('div.content a[href*="help.steam"]', loops=6)
self.highlight('#store_nav_area', loops=2, scroll=False)
self.highlight("#store_nav_area", loops=2, scroll=False)
self.highlight("#foryou_tab a", loops=1, scroll=False)
self.highlight("#noteworthy_tab a", loops=3, scroll=False)
self.highlight("#genre_tab a", loops=1, scroll=False)
@ -222,7 +222,7 @@ class HackTests(BaseCase):
self.remove_element('li:contains("What")')
self.remove_element('li:contains("WI")')
self.set_attributes("#news img", "src", sb_banner_logo)
self.set_text_content('#ctitle', aybabtu)
self.set_text_content("#ctitle", aybabtu)
self.set_text_content('a[rel="prev"]', "All")
self.set_text_content('a[href*="random"]', "Your")
self.set_text_content('a[rel="next"]', "Base")
@ -270,8 +270,8 @@ class HackTests(BaseCase):
self.set_text_content('nav a[href="/partners/"]', "ARE")
self.set_text_content('nav a[href="/community/"]', "BELONG")
self.set_text_content('nav a[href="/case-studies/"]', "TO")
self.set_text_content('nav #navbarDropdown', "US")
self.set_text_content('nav #navbarDropdownMenuLink', ".")
self.set_text_content("nav #navbarDropdown", "US")
self.set_text_content("nav #navbarDropdownMenuLink", ".")
if self.is_element_visible("h1"):
self.set_text_content("h1", aybabtu)
self.highlight("nav ul.navbar-nav", loops=3, scroll=False)
@ -281,9 +281,9 @@ class HackTests(BaseCase):
self.highlight('nav a[href="/partners/"]', loops=1, scroll=False)
self.highlight('nav a[href="/community/"]', loops=1, scroll=False)
self.highlight('nav a[href="/case-studies/"]', loops=1, scroll=False)
self.highlight('nav #navbarDropdown', loops=2, scroll=False)
self.highlight("nav #navbarDropdown", loops=2, scroll=False)
if self.is_element_visible("h1"):
self.highlight('h1', loops=6, scroll=False)
self.highlight("h1", loops=6, scroll=False)
self.open("https://www.selenium.dev/")
if self.is_element_visible('button[data-dismiss="alert"] span'):
@ -298,7 +298,7 @@ class HackTests(BaseCase):
self.set_text_content('li a:contains("English")', "US")
self.set_text_content("div.lead", aybabtu)
self.set_text_content("h2", aybabtu)
zoom_in = 'div.lead{zoom: 1.25;-moz-transform: scale(1.25);}'
zoom_in = "div.lead{zoom: 1.25;-moz-transform: scale(1.25);}"
self.add_css_style(zoom_in)
self.highlight("div#main_navbar", loops=1, scroll=False)
self.highlight('li a:contains("ALL")', loops=1, scroll=False)
@ -401,7 +401,7 @@ class HackTests(BaseCase):
self.open("https://pragprog.com/")
self.set_text_content("header p", aybabtu)
zoom_in = 'header p{zoom: 1.35;-moz-transform: scale(1.35);}'
zoom_in = "header p{zoom: 1.35;-moz-transform: scale(1.35);}"
self.add_css_style(zoom_in)
self.highlight("header p", loops=10, scroll=False)

View File

@ -6,7 +6,7 @@ from seleniumbase import BaseCase
class ImageTests(BaseCase):
@pytest.mark.run(order=1)
def test_pull_image_from_website(self):
""" Pull an image from a website and save it as a PNG file. """
"""Pull an image from a website and save it as a PNG file."""
self.open("https://xkcd.com/1117/")
selector = "#comic"
file_name = "comic.png"
@ -17,7 +17,7 @@ class ImageTests(BaseCase):
@pytest.mark.run(order=2)
def test_add_text_overlay_to_image(self):
""" Add a text overlay to an image. """
"""Add a text overlay to an image."""
self.open("https://xkcd.com/1117/")
selector = "#comic"
file_name = "image_overlay.png"
@ -31,7 +31,7 @@ class ImageTests(BaseCase):
@pytest.mark.run(order=3)
def test_add_text_overlay_to_page_section(self):
""" Add a text overlay to a section of a page. """
"""Add a text overlay to a section of a page."""
self.open("https://xkcd.com/2200/")
selector = "#middleContainer"
file_name = "section_overlay.png"
@ -50,7 +50,7 @@ class ImageTests(BaseCase):
@pytest.mark.run(order=4)
def test_add_text_overlay_to_full_page(self):
""" Add a text overlay to a full page. """
"""Add a text overlay to a full page."""
self.open("https://xkcd.com/1922/")
self.remove_element("#bottom")
selector = "body"

View File

@ -7,7 +7,7 @@ class MasterQATests(MasterQA):
self.highlight("div.mockup-wrapper")
self.verify("Do you see 4 computer devices?")
self.open("https://seleniumbase.io/demo_page")
self.highlight('table')
self.highlight("table")
self.verify("Do you see elements in a table?")
self.open("https://xkcd.com/1700/")
self.highlight("#comic")

View File

@ -4,7 +4,7 @@ from seleniumbase import BaseCase
class SwagLabsTests(BaseCase):
def login_to_swag_labs(self, username="standard_user"):
""" Login to Swag Labs and verify success. """
"""Login to Swag Labs and verify success."""
url = "https://www.saucedemo.com"
self.open(url)
if username not in self.get_text("#login_credentials"):

View File

@ -23,12 +23,13 @@ class UserAgentTests(BaseCase):
print("\n--------------------------")
try:
self.driver.execute_cdp_cmd(
"Network.setUserAgentOverride", {
"Network.setUserAgentOverride",
{
"userAgent": "Mozilla/5.0 "
"(Nintendo Switch; WifiWebAuthApplet) "
"AppleWebKit/606.4 (KHTML, like Gecko) "
"NF/6.0.1.15.4 NintendoBrowser/5.1.0.20393"
}
"(Nintendo Switch; WifiWebAuthApplet) "
"AppleWebKit/606.4 (KHTML, like Gecko) "
"NF/6.0.1.15.4 NintendoBrowser/5.1.0.20393"
},
)
self.open("http://whatsmyuseragent.org/")
user_agent_detected = self.get_text(".user-agent p")
@ -38,7 +39,6 @@ class UserAgentTests(BaseCase):
finally:
# Reset the user-agent back to the original
self.driver.execute_cdp_cmd(
"Network.setUserAgentOverride", {
"userAgent": original_user_agent
}
"Network.setUserAgentOverride",
{"userAgent": original_user_agent},
)

View File

@ -19,7 +19,7 @@ class AppleTests(BaseCase):
title = "Testing with WebDriver in Safari"
self.type('[placeholder*="developer.apple.com"]', title + "\n")
self.click("link=%s" % title)
self.assert_element('nav.documentation-nav')
self.assert_element("nav.documentation-nav")
self.assert_text(title, "h1")
self.highlight("div.description div.abstract")
self.highlight("h2")

View File

@ -16,7 +16,7 @@ class CanvasTests(BaseCase):
if self.is_chromium():
return [color[0], color[1], color[2]]
else:
return [color['0'], color['1'], color['2']]
return [color["0"], color["1"], color["2"]]
def test_canvas_actions(self):
self.open("https://seleniumbase.io/canvas/")

View File

@ -22,10 +22,9 @@ class DemoSiteTests(BaseCase):
# Verify that a hover dropdown link changes page text
self.assert_text("Automation Practice", "h3")
try:
self.hover_and_click(
"#myDropdown", "#dropOption2", timeout=2)
self.hover_and_click("#myDropdown", "#dropOption2", timeout=1)
except Exception:
# If a human moves the mouse while the test runs
# If someone moves the mouse while the test runs
self.js_click("#dropOption2")
self.assert_text("Link Two Selected", "h3")

View File

@ -18,7 +18,7 @@ class FrameTests(BaseCase):
self.set_content_to_frame("iframeResult")
self.highlight('iframe[title="Iframe Example"]')
self.set_content_to_frame("iframe")
self.assert_element_not_visible('iframe')
self.assert_element_not_visible("iframe")
self.highlight("body")
self.set_content_to_default(nested=False)
self.highlight('iframe[title="Iframe Example"]')

View File

@ -3,14 +3,14 @@ from seleniumbase import BaseCase
class SwagLabsLoginTests(BaseCase):
def login_to_swag_labs(self):
""" Login to Swag Labs and verify that login was successful. """
"""Login to Swag Labs and verify that login was successful."""
self.open("https://www.saucedemo.com")
self.type("#user-name", "standard_user")
self.type("#password", "secret_sauce")
self.click('input[type="submit"]')
def test_swag_labs_login(self):
""" This test checks standard login for the Swag Labs store. """
"""This test checks standard login for the Swag Labs store."""
self.login_to_swag_labs()
self.assert_element("#inventory_container")
self.assert_element('.inventory_item:contains("Sauce Labs Backpack")')

View File

@ -3,9 +3,8 @@ from seleniumbase import BaseCase
class OverrideDriverTest(BaseCase):
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.add_experimental_option(
"excludeSwitches", ["enable-automation"]

View File

@ -23,7 +23,7 @@ def test_repeat_this_test_with_pytest_parametrize(sb):
sb.assert_text("Console Scripts", "h1")
class RepeatTestsWithPytest():
class RepeatTestsWithPytest:
@pytest.mark.parametrize("", [[]] * 2)
def test_repeat_test_with_pytest_parametrize(self, sb):
sb.open("https://seleniumbase.io")

View File

@ -3,7 +3,7 @@ from seleniumbase import BaseCase
class SwagLabsTests(BaseCase):
def login_to_swag_labs(self, username="standard_user"):
""" Login to Swag Labs and verify success. """
"""Login to Swag Labs and verify success."""
self.open("https://www.saucedemo.com")
if username not in self.get_text("#login_credentials"):
self.fail("Invalid user for login: %s" % username)
@ -14,7 +14,7 @@ class SwagLabsTests(BaseCase):
self.assert_element('.inventory_item:contains("Sauce Labs Backpack")')
def test_swag_labs_basic_flow(self):
""" This test checks functional flow of the Swag Labs store. """
"""This test checks functional flow of the Swag Labs store."""
self.login_to_swag_labs(username="standard_user")
# Verify that the "Test.allTheThings() T-Shirt" appears on the page

View File

@ -70,7 +70,7 @@ class MyTourClass(BaseCase):
alignment="left",
)
self.add_tour_step(
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour",
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour"
)
self.export_tour(filename="bootstrap_google_maps_tour.js")
self.play_tour()

View File

@ -47,7 +47,7 @@ class MyTestClass(BaseCase):
alignment="left",
)
self.add_tour_step(
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour",
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour"
)
self.export_tour() # The default name for exports is "my_tour.js"
self.play_tour(interval=0) # If interval > 0, autoplay after N seconds

View File

@ -78,7 +78,7 @@ class MyTourClass(BaseCase):
alignment="left",
)
self.add_tour_step(
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour",
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour"
)
self.export_tour() # The default name for exports is "my_tour.js"
self.play_tour()

View File

@ -70,7 +70,7 @@ class MyTourClass(BaseCase):
alignment="left",
)
self.add_tour_step(
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour",
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour"
)
self.export_tour(filename="hopscotch_google_maps_tour.js")
self.play_tour()

View File

@ -71,7 +71,7 @@ class MyTourClass(BaseCase):
alignment="left",
)
self.add_tour_step(
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour",
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour"
)
self.export_tour(filename="introjs_google_maps_tour.js")
self.play_tour()

View File

@ -45,7 +45,7 @@ class MyTourClass(BaseCase):
alignment="left",
)
self.add_tour_step(
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour",
"Thanks for using SeleniumBase Tours!", title="End of Guided Tour"
)
self.export_tour(filename="maps_introjs_tour.js")
self.play_tour()

View File

@ -7,7 +7,7 @@ import subprocess
import sys
class TestUpgradeChromedriver():
class TestUpgradeChromedriver:
def basic_run(self, testdir):
testdir.makepyfile(
"""

View File

@ -23,12 +23,13 @@ class UserAgentTests(BaseCase):
# Now change the user-agent using "execute_cdp_cmd()"
print("--------------------------")
self.driver.execute_cdp_cmd(
"Network.setUserAgentOverride", {
"Network.setUserAgentOverride",
{
"userAgent": "Mozilla/5.0 "
"(Nintendo Switch; WifiWebAuthApplet) "
"AppleWebKit/606.4 (KHTML, like Gecko) "
"NF/6.0.1.15.4 NintendoBrowser/5.1.0.20393"
}
"(Nintendo Switch; WifiWebAuthApplet) "
"AppleWebKit/606.4 (KHTML, like Gecko) "
"NF/6.0.1.15.4 NintendoBrowser/5.1.0.20393"
},
)
self.open("https://www.whatsmyua.info/")
user_agent_detected = self.get_text("#custom-ua-string")
@ -37,7 +38,6 @@ class UserAgentTests(BaseCase):
finally:
# Reset the user-agent back to the original
self.driver.execute_cdp_cmd(
"Network.setUserAgentOverride", {
"userAgent": original_user_agent
}
"Network.setUserAgentOverride",
{"userAgent": original_user_agent},
)

View File

@ -3,7 +3,7 @@
from seleniumbase import BaseCase
class VisualLayout_FixtureTests():
class VisualLayout_FixtureTests:
def test_python_home_change(self, sb):
sb.open("https://python.org/")
print('\nCreating baseline in "visual_baseline" folder.')

View File

@ -76,7 +76,7 @@ class WordleTests(BaseCase):
letters.append(letter)
button = 'button[data-key="%s"]' % letter
self.click(keyboard_base + button)
button = 'button.one-and-a-half'
button = "button.one-and-a-half"
self.click(keyboard_base + button)
row = 'game-app::shadow game-row[letters="%s"]::shadow ' % word
tile = row + "game-tile:nth-of-type(%s)"

View File

@ -8,4 +8,4 @@ class XPathTests(BaseCase):
self.type('//*[@id="myTextInput"]', "XPath Test!")
self.click('//button[starts-with(text(),"Click Me")]')
self.assert_element('//button[contains(., "Purple")]')
self.assert_text("SeleniumBase", '//table/tbody/tr[1]/td[2]/h2')
self.assert_text("SeleniumBase", "//table/tbody/tr[1]/td[2]/h2")

View File

@ -3,7 +3,7 @@ from seleniumbase import BaseCase
class YouTubeSearchTests(BaseCase):
def test_youtube_autocomplete_results(self):
""" Verify YouTube autocomplete search results. """
"""Verify YouTube autocomplete search results."""
self.open("https://www.youtube.com/c/MichaelMintz")
search_term = "seleniumbase"
search_selector = "input#search"
@ -18,14 +18,13 @@ class YouTubeSearchTests(BaseCase):
self.assert_true(
search_term in top_result,
'Expected text "%s" not found in top result! '
'Actual text was "%s"!'
% (search_term, top_result)
'Actual text was "%s"!' % (search_term, top_result),
)
self.click(result_selector)
self.assert_element_present('a[aria-label*="SeleniumBase"]')
def test_youtube_search_results(self):
""" Verify finding a specific video by performing a YouTube search. """
"""Verify finding a specific video by performing a YouTube search."""
self.open("https://www.youtube.com/c/MichaelMintz")
search_term = "SeleniumBase Common API Methods"
search_selector = "input#search"