Update example tests
This commit is contained in:
parent
e52ca717f0
commit
7612313c3f
|
@ -8,7 +8,7 @@ class GoogleTests(BaseCase):
|
|||
def test_google_dot_com(self):
|
||||
self.open("https://google.com/ncr")
|
||||
self.sleep(0.1)
|
||||
self.save_screenshot_to_logs() # In "./latest_logs/" folder.
|
||||
self.save_screenshot_to_logs() # ("./latest_logs" folder)
|
||||
self.type(HomePage.search_box, "github.com")
|
||||
self.assert_element(HomePage.search_button)
|
||||
self.assert_element(HomePage.feeling_lucky_button)
|
||||
|
|
|
@ -3,10 +3,11 @@ from seleniumbase import BaseCase
|
|||
|
||||
class GitHubTests(BaseCase):
|
||||
def test_github(self):
|
||||
if self.headless:
|
||||
if self.headless or self.page_load_strategy == "none":
|
||||
self.open_if_not_url("about:blank")
|
||||
print("\n This test is not for Headless Mode.")
|
||||
self.skip('Do not use "--headless" with this test.')
|
||||
message = "Unsupported mode for this test."
|
||||
print("\n " + message)
|
||||
self.skip(message)
|
||||
self.open("https://github.com/search?q=SeleniumBase")
|
||||
self.slow_click('a[href="/seleniumbase/SeleniumBase"]')
|
||||
self.click_if_visible('[data-action="click:signup-prompt#dismiss"]')
|
||||
|
|
|
@ -69,7 +69,7 @@ class MyTestClass(BaseCase):
|
|||
# * Wait for the element to be interactive
|
||||
# * Clear the text field
|
||||
# * Type in the new text
|
||||
# * Press Enter/Submit if the text ends in "\n"
|
||||
# * Press Enter/Return if the text ends in "\n": {element.submit()}
|
||||
#
|
||||
# 4. Duplicate method names may exist for the same method:
|
||||
# (This makes it easier to switch over from other test frameworks.)
|
||||
|
|
|
@ -5,12 +5,13 @@ class NthChildSelectorTests(BaseCase):
|
|||
def test_locate_rows_with_colors(self):
|
||||
self.open("https://xkcd.com/color/rgb/")
|
||||
tbody = "center > table tbody"
|
||||
if not (self.headless or self.xvfb):
|
||||
if not (self.headless or self.headless2 or self.xvfb):
|
||||
self.demo_mode = True
|
||||
self.demo_sleep = 0.5
|
||||
self.message_duration = 2.0
|
||||
else:
|
||||
self.message_duration = 0.2
|
||||
self.demo_mode = False
|
||||
self.message_duration = 0.1
|
||||
self.highlight(tbody)
|
||||
self.post_message("Part 1: Assert text in given row.")
|
||||
self.assert_text("teal", tbody + " tr:nth-child(2)")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.5">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.41, shrink-to-fit=no">
|
||||
<title>Web Testing Page</title>
|
||||
<style>
|
||||
html {
|
||||
|
@ -263,7 +263,7 @@
|
|||
<body>
|
||||
<!-- Tested with SeleniumBase - https://seleniumbase.io -->
|
||||
<form id="myForm">
|
||||
<table id="myTable" style="width: 780px; padding: 10px;">
|
||||
<table id="myTable" style="width: 804px; padding: 10px;">
|
||||
<tbody id="tbodyId">
|
||||
<tr>
|
||||
<td>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[pytest]
|
||||
|
||||
# Display console output, disable cacheprovider, and have the ipdb debugger replace pdb:
|
||||
addopts = --capture=no -p no:cacheprovider --pdbcls=IPython.terminal.debugger:TerminalPdb
|
||||
# Display console output, disable cacheprovider:
|
||||
addopts = --capture=no -p no:cacheprovider
|
||||
|
||||
# Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning
|
||||
filterwarnings =
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
exclude=recordings,temp
|
||||
ignore=W503
|
||||
|
||||
[ipdb]
|
||||
context=5
|
||||
|
||||
[nosetests]
|
||||
# nocapture=1 (Display print statements from output)
|
||||
# (Undo this by using: "--nologcapture")
|
||||
|
|
|
@ -13,7 +13,8 @@ class UserAgentTests(BaseCase):
|
|||
# User-agent was overridden using: --agent=STRING
|
||||
self._print("\n\nUser-Agent override: %s" % user_agent_detected)
|
||||
print("\n" + self.get_text(".ip-address p"))
|
||||
self.sleep(3)
|
||||
if not (self.headless or self.headless2 or self.xvfb):
|
||||
self.sleep(3)
|
||||
|
||||
# Now change the user-agent using "execute_cdp_cmd()"
|
||||
if not self.is_chromium():
|
||||
|
@ -35,7 +36,8 @@ class UserAgentTests(BaseCase):
|
|||
user_agent_detected = self.get_text(".user-agent p")
|
||||
self._print("\nUser-Agent override: %s" % user_agent_detected)
|
||||
print("\n" + self.get_text(".ip-address p") + "\n")
|
||||
self.sleep(3)
|
||||
if not (self.headless or self.headless2 or self.xvfb):
|
||||
self.sleep(3)
|
||||
finally:
|
||||
# Reset the user-agent back to the original
|
||||
self.driver.execute_cdp_cmd(
|
||||
|
|
|
@ -5,7 +5,7 @@ from seleniumbase import BaseCase
|
|||
class CoffeeCartTest(BaseCase):
|
||||
def test_coffee_cart(self):
|
||||
self.open("https://coffee-cart.netlify.app/")
|
||||
self.click('div[data-test="Cappucino"]')
|
||||
self.click('div[data-test="Cappuccino"]')
|
||||
self.click('div[data-test="Cafe_Latte"]')
|
||||
self.click('div[data-test="Cafe_Breve"]')
|
||||
self.click('a[aria-label="Cart page"]')
|
||||
|
|
|
@ -49,8 +49,9 @@ class DownloadTests(BaseCase):
|
|||
self.download_file(whl_href)
|
||||
self.download_file(tar_href)
|
||||
else:
|
||||
self.click(whl_selector)
|
||||
self.click(tar_selector)
|
||||
self.click(whl_selector) # Download the "whl" file
|
||||
self.sleep(0.1)
|
||||
self.click(tar_selector) # Download the "tar" file
|
||||
|
||||
# Verify that the downloaded files appear in the [Downloads Folder]
|
||||
# (This only guarantees that the exact file name is in the folder.)
|
||||
|
|
|
@ -12,8 +12,8 @@ class UserAgentTests(BaseCase):
|
|||
else:
|
||||
# User-agent was overridden using: --agent=STRING
|
||||
self._print("\n\nUser-Agent override = %s\n" % user_agent_detected)
|
||||
self.sleep(3)
|
||||
|
||||
if not (self.headless or self.headless2 or self.xvfb):
|
||||
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"
|
||||
|
@ -34,7 +34,8 @@ class UserAgentTests(BaseCase):
|
|||
self.open("https://www.whatsmyua.info/")
|
||||
user_agent_detected = self.get_text("#custom-ua-string")
|
||||
self._print("\nUser-Agent override = %s\n" % user_agent_detected)
|
||||
self.sleep(3)
|
||||
if not (self.headless or self.headless2 or self.xvfb):
|
||||
self.sleep(3)
|
||||
finally:
|
||||
# Reset the user-agent back to the original
|
||||
self.driver.execute_cdp_cmd(
|
||||
|
|
|
@ -6,13 +6,13 @@ class VisualLayoutTests(BaseCase):
|
|||
self.open("https://applitools.com/helloworld?diff1")
|
||||
self.wait_for_element('a[href="?diff1"]')
|
||||
print('\nCreating baseline in "visual_baseline" folder.')
|
||||
self.sleep(0.05)
|
||||
self.sleep(0.06)
|
||||
self.check_window(name="helloworld", baseline=True)
|
||||
# Click a button that changes the text of an element
|
||||
# (Text changes do not impact visual comparisons)
|
||||
self.sleep(0.05)
|
||||
self.sleep(0.06)
|
||||
self.click('a[href="?diff1"]')
|
||||
self.sleep(0.05)
|
||||
self.sleep(0.06)
|
||||
# Verify html tags match the baseline
|
||||
self.check_window(name="helloworld", level=1)
|
||||
# Verify html tags and attribute names match the baseline
|
||||
|
|
Loading…
Reference in New Issue