Update examples

This commit is contained in:
Michael Mintz 2020-08-17 21:40:48 -04:00
parent 8cbbd19d75
commit b8e29d4534
3 changed files with 22 additions and 5 deletions

View File

@ -5,7 +5,7 @@ from seleniumbase import BaseCase
class SwagLabsTests(BaseCase):
def login(self, username="standard_user"):
def login_to_swag_labs(self, username="standard_user"):
""" Login to Swag Labs and verify that login was successful. """
self.open("https://www.saucedemo.com/")
if username not in self.get_text("#login_credentials"):
@ -24,7 +24,7 @@ class SwagLabsTests(BaseCase):
def test_swag_labs_basic_functional_flow(self, username):
""" This test checks functional flow of the Swag Labs store.
This test is parameterized, and receives the user for login. """
self.login(username=username)
self.login_to_swag_labs(username=username)
# Verify that the "Test.allTheThings() T-Shirt" appears on the page
item_name = "Test.allTheThings() T-Shirt"
@ -87,5 +87,5 @@ class SwagLabsTests(BaseCase):
def test_swag_labs_products_page_resource_verification(self, username):
""" This test checks for 404 errors on the Swag Labs products page.
This test is parameterized, and receives the user for login. """
self.login(username=username)
self.login_to_swag_labs(username=username)
self.assert_no_404_errors()

17
examples/test_login.py Executable file
View File

@ -0,0 +1,17 @@
from seleniumbase import BaseCase
class SwagLabsLoginTests(BaseCase):
def login_to_swag_labs(self):
""" 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. """
self.login_to_swag_labs()
self.assert_element("div.header_label div.app_logo")
self.assert_text("Products", "div.product_label")

View File

@ -3,7 +3,7 @@ from seleniumbase import BaseCase
class SwagLabsTests(BaseCase):
def login(self, username="standard_user"):
def login_to_swag_labs(self, username="standard_user"):
""" Login to Swag Labs and verify that login was successful. """
self.open("https://www.saucedemo.com/")
if username not in self.get_text("#login_credentials"):
@ -16,7 +16,7 @@ class SwagLabsTests(BaseCase):
def test_swag_labs_basic_flow(self):
""" This test checks functional flow of the Swag Labs store. """
self.login(username="standard_user")
self.login_to_swag_labs(username="standard_user")
# Verify that the "Test.allTheThings() T-Shirt" appears on the page
item_name = "Test.allTheThings() T-Shirt"