Update example tests

This commit is contained in:
Michael Mintz 2021-12-03 00:09:07 -05:00
parent 6aeebf2847
commit 5e9ec258d4
3 changed files with 18 additions and 18 deletions

View File

@ -9,14 +9,12 @@ class GitHubTests(BaseCase):
# To avoid this automation blocker, two steps are being taken: # To avoid this automation blocker, two steps are being taken:
# 1. self.slow_click() is being used to slow down Selenium actions. # 1. self.slow_click() is being used to slow down Selenium actions.
# 2. The browser's User Agent is modified to avoid Selenium-detection # 2. The browser's User Agent is modified to avoid Selenium-detection
# when running in headless mode on Chrome or Edge (Chromium). # when running in headless mode.
if self.headless and ( if self.headless:
self.browser == "chrome" or self.browser == "edge"
):
self.get_new_driver( self.get_new_driver(
agent="""Mozilla/5.0 """ agent="""Mozilla/5.0 """
"""AppleWebKit/537.36 (KHTML, like Gecko) """ """AppleWebKit/537.36 (KHTML, like Gecko) """
"""Chrome/92.0.4515.159 Safari/537.36""" """Chrome/Version 96.0.4664.55 Safari/537.36"""
) )
self.open("https://github.com/search?q=SeleniumBase") self.open("https://github.com/search?q=SeleniumBase")
self.slow_click('a[href="/seleniumbase/SeleniumBase"]') self.slow_click('a[href="/seleniumbase/SeleniumBase"]')

View File

@ -3,8 +3,6 @@ from seleniumbase import BaseCase
class HandleAlertTests(BaseCase): class HandleAlertTests(BaseCase):
def test_alerts(self): def test_alerts(self):
if self.browser == "safari":
self.skip("This test doesn't run on Safari! (alert issues)")
self.open("about:blank") self.open("about:blank")
self.execute_script('window.alert("ALERT!!!");') self.execute_script('window.alert("ALERT!!!");')
self.sleep(1) # Not needed (Lets you see the alert pop up) self.sleep(1) # Not needed (Lets you see the alert pop up)

View File

@ -1,6 +1,19 @@
""" Visual Layout Testing with different Syntax Formats """
from seleniumbase import BaseCase from seleniumbase import BaseCase
class VisualLayout_FixtureTests():
def test_python_home_change(sb):
sb.open("https://python.org/")
print('\nCreating baseline in "visual_baseline" folder.')
sb.check_window(name="python_home", baseline=True)
# Remove the "Donate" button
sb.remove_element("a.donate-button")
print("(This test should fail)") # due to missing button
sb.check_window(name="python_home", level=3)
class VisualLayoutFailureTests(BaseCase): class VisualLayoutFailureTests(BaseCase):
def test_applitools_change(self): def test_applitools_change(self):
self.open("https://applitools.com/helloworld?diff1") self.open("https://applitools.com/helloworld?diff1")
@ -10,18 +23,9 @@ class VisualLayoutFailureTests(BaseCase):
self.click('a[href="?diff1"]') self.click('a[href="?diff1"]')
# Click a button that makes a hidden element visible # Click a button that makes a hidden element visible
self.click("button") self.click("button")
print("(This test should fail)") print("(This test should fail)") # due to image now seen
self.check_window(name="helloworld", level=3) self.check_window(name="helloworld", level=3)
def test_python_home_change(self):
self.open("https://python.org/")
print('\nCreating baseline in "visual_baseline" folder.')
self.check_window(name="python_home", baseline=True)
# Remove the "Donate" button
self.remove_element("a.donate-button")
print("(This test should fail)")
self.check_window(name="python_home", level=3)
def test_xkcd_logo_change(self): def test_xkcd_logo_change(self):
self.open("https://xkcd.com/554/") self.open("https://xkcd.com/554/")
print('\nCreating baseline in "visual_baseline" folder.') print('\nCreating baseline in "visual_baseline" folder.')
@ -29,5 +33,5 @@ class VisualLayoutFailureTests(BaseCase):
# Change height: (83 -> 110) , Change width: (185 -> 120) # Change height: (83 -> 110) , Change width: (185 -> 120)
self.set_attribute('[alt="xkcd.com logo"]', "height", "110") self.set_attribute('[alt="xkcd.com logo"]', "height", "110")
self.set_attribute('[alt="xkcd.com logo"]', "width", "120") self.set_attribute('[alt="xkcd.com logo"]', "width", "120")
print("(This test should fail)") print("(This test should fail)") # due to a resized logo
self.check_window(name="xkcd_554", level=3) self.check_window(name="xkcd_554", level=3)