Update the example tests

This commit is contained in:
Michael Mintz 2022-02-01 14:56:26 -05:00
parent 9835426000
commit f620144a72
8 changed files with 17 additions and 15 deletions

View File

@ -1,5 +1,5 @@
"""
Add an item to a shopping cart, and verify.
Add an item to a shopping cart; verify; remove item; verify.
"""
from seleniumbase import BaseCase
@ -15,4 +15,6 @@ class MyTestClass(BaseCase):
self.click("#shopping_cart_container a")
self.assert_exact_text("YOUR CART", "span.title")
self.assert_text("Backpack", "div.cart_item")
self.click('button:contains("Remove")') # HTML innerText
self.assert_text_not_visible("Backpack", "div.cart_item")
self.js_click("a#logout_sidebar_link")

View File

@ -13,10 +13,10 @@ class AngularJSHomePageTests(BaseCase):
# Verify that the todos are listed
todos = self.find_visible_elements(todo_selector)
self.assert_equal(len(todos), 2)
self.assert_equal(todos[1].text, "build an AngularJS app")
self.assert_equal(todos[1].text.strip(), "build an AngularJS app")
# Verify adding a new todo
self.type('[ng-model="todoList.todoText"]', "write a protractor test")
self.click('[value="add"]')
todos = self.find_visible_elements(todo_selector)
self.assert_equal(len(todos), 3)
self.assert_equal(todos[2].text, "write a protractor test")
self.assert_equal(todos[2].text.strip(), "write a protractor test")

View File

@ -81,7 +81,7 @@
margin: 2px;
}
h1 {
font-size: 25px;
font-size: 24px;
color:#0066AA;
}
h2 {

View File

@ -5,8 +5,6 @@ from seleniumbase import BaseCase
@pytest.mark.offline # Can be run with: "pytest -m offline"
class OfflineTests(BaseCase):
def test_alerts(self):
if self.browser == "safari":
self.skip("This test doesn't run on Safari! (alert issues)")
self.open("data:,")
self.execute_script('window.alert("ALERT!!!");')
self.sleep(1) # Not needed (Lets you see the alert pop up)

View File

@ -29,7 +29,7 @@ except (ImportError, ValueError):
pure_python = True
if pure_python:
sb = MyTestClass("test_basics")
sb = MyTestClass("test_swag_labs")
sb.browser = "chrome"
sb.headless = False
sb.headed = False
@ -101,7 +101,7 @@ if pure_python:
sb.setUp()
try:
sb.test_basics()
sb.test_swag_labs()
finally:
sb.tearDown()
del sb

View File

@ -72,7 +72,7 @@ class SwagLabsTests(BaseCase):
self.click("button#finish")
self.assert_exact_text("THANK YOU FOR YOUR ORDER", "h2")
self.assert_element("img.pony_express")
self.click("#shopping_cart_container")
self.click("#shopping_cart_container a")
self.assert_element_absent("div.inventory_item_name")
self.click("button#continue-shopping")
self.assert_element_absent("span.shopping_cart_badge")

View File

@ -21,7 +21,8 @@ class FileUpload(BaseCase):
my_file = "screenshot.png"
file_path = os.path.join(dir_name, "example_logs/%s" % my_file)
self.choose_file(choose_file_selector, file_path)
seen_path = "%s\\%s" % ("C:\\fakepath", my_file)
self.assert_attribute(choose_file_selector, "value", seen_path)
if self.browser != "safari":
seen_path = "%s\\%s" % ("C:\\fakepath", my_file)
self.assert_attribute(choose_file_selector, "value", seen_path)
self.demo_mode = True
self.assert_element(uploaded_image)

View File

@ -14,12 +14,13 @@ class UserAgentTests(BaseCase):
print("\n\nUser-Agent override = %s\n" % user_agent_detected)
self.sleep(3)
if not self.is_chromium():
# Skip the rest of the test if not using a Chromium browser
msg = "\n* execute_cdp_cmd() is only for Chromium browsers"
print(msg)
self.skip(msg)
try:
# Now change the user-agent using "execute_cdp_cmd()"
if not self.is_chromium():
msg = "\n* execute_cdp_cmd() is only for Chromium browsers"
print(msg)
self.skip(msg)
print("--------------------------")
self.driver.execute_cdp_cmd(
"Network.setUserAgentOverride", {