Skip to content

Commit 7612313

Browse files
committed
Update example tests
1 parent e52ca71 commit 7612313

File tree

12 files changed

+28
-25
lines changed

12 files changed

+28
-25
lines changed

examples/boilerplates/samples/google_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class GoogleTests(BaseCase):
88
def test_google_dot_com(self):
99
self.open("https://google.com/ncr")
1010
self.sleep(0.1)
11-
self.save_screenshot_to_logs() # In "./latest_logs/" folder.
11+
self.save_screenshot_to_logs() # ("./latest_logs" folder)
1212
self.type(HomePage.search_box, "github.com")
1313
self.assert_element(HomePage.search_button)
1414
self.assert_element(HomePage.feeling_lucky_button)

examples/github_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
class GitHubTests(BaseCase):
55
def test_github(self):
6-
if self.headless:
6+
if self.headless or self.page_load_strategy == "none":
77
self.open_if_not_url("about:blank")
8-
print("\n This test is not for Headless Mode.")
9-
self.skip('Do not use "--headless" with this test.')
8+
message = "Unsupported mode for this test."
9+
print("\n " + message)
10+
self.skip(message)
1011
self.open("https://github.com/search?q=SeleniumBase")
1112
self.slow_click('a[href="/seleniumbase/SeleniumBase"]')
1213
self.click_if_visible('[data-action="click:signup-prompt#dismiss"]')

examples/my_first_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_swag_labs(self):
6969
# * Wait for the element to be interactive
7070
# * Clear the text field
7171
# * Type in the new text
72-
# * Press Enter/Submit if the text ends in "\n"
72+
# * Press Enter/Return if the text ends in "\n": {element.submit()}
7373
#
7474
# 4. Duplicate method names may exist for the same method:
7575
# (This makes it easier to switch over from other test frameworks.)

examples/nth_child_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ class NthChildSelectorTests(BaseCase):
55
def test_locate_rows_with_colors(self):
66
self.open("https://xkcd.com/color/rgb/")
77
tbody = "center > table tbody"
8-
if not (self.headless or self.xvfb):
8+
if not (self.headless or self.headless2 or self.xvfb):
99
self.demo_mode = True
1010
self.demo_sleep = 0.5
1111
self.message_duration = 2.0
1212
else:
13-
self.message_duration = 0.2
13+
self.demo_mode = False
14+
self.message_duration = 0.1
1415
self.highlight(tbody)
1516
self.post_message("Part 1: Assert text in given row.")
1617
self.assert_text("teal", tbody + " tr:nth-child(2)")

examples/offline_examples/demo_page.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<html>
22
<head>
33
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4-
<meta name="viewport" content="width=device-width, initial-scale=0.5">
4+
<meta name="viewport" content="width=device-width, initial-scale=0.41, shrink-to-fit=no">
55
<title>Web Testing Page</title>
66
<style>
77
html {
@@ -263,7 +263,7 @@
263263
<body>
264264
<!-- Tested with SeleniumBase - https://seleniumbase.io -->
265265
<form id="myForm">
266-
<table id="myTable" style="width: 780px; padding: 10px;">
266+
<table id="myTable" style="width: 804px; padding: 10px;">
267267
<tbody id="tbodyId">
268268
<tr>
269269
<td>

examples/pytest.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[pytest]
22

3-
# Display console output, disable cacheprovider, and have the ipdb debugger replace pdb:
4-
addopts = --capture=no -p no:cacheprovider --pdbcls=IPython.terminal.debugger:TerminalPdb
3+
# Display console output, disable cacheprovider:
4+
addopts = --capture=no -p no:cacheprovider
55

66
# Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning
77
filterwarnings =

examples/setup.cfg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
exclude=recordings,temp
44
ignore=W503
55

6-
[ipdb]
7-
context=5
8-
96
[nosetests]
107
# nocapture=1 (Display print statements from output)
118
# (Undo this by using: "--nologcapture")

examples/test_agent.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def test_user_agent(self):
1313
# User-agent was overridden using: --agent=STRING
1414
self._print("\n\nUser-Agent override: %s" % user_agent_detected)
1515
print("\n" + self.get_text(".ip-address p"))
16-
self.sleep(3)
16+
if not (self.headless or self.headless2 or self.xvfb):
17+
self.sleep(3)
1718

1819
# Now change the user-agent using "execute_cdp_cmd()"
1920
if not self.is_chromium():
@@ -35,7 +36,8 @@ def test_user_agent(self):
3536
user_agent_detected = self.get_text(".user-agent p")
3637
self._print("\nUser-Agent override: %s" % user_agent_detected)
3738
print("\n" + self.get_text(".ip-address p") + "\n")
38-
self.sleep(3)
39+
if not (self.headless or self.headless2 or self.xvfb):
40+
self.sleep(3)
3941
finally:
4042
# Reset the user-agent back to the original
4143
self.driver.execute_cdp_cmd(

examples/test_coffee_cart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class CoffeeCartTest(BaseCase):
66
def test_coffee_cart(self):
77
self.open("https://coffee-cart.netlify.app/")
8-
self.click('div[data-test="Cappucino"]')
8+
self.click('div[data-test="Cappuccino"]')
99
self.click('div[data-test="Cafe_Latte"]')
1010
self.click('div[data-test="Cafe_Breve"]')
1111
self.click('a[aria-label="Cart page"]')

examples/test_download_files.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def test_download_files_from_pypi(self):
4949
self.download_file(whl_href)
5050
self.download_file(tar_href)
5151
else:
52-
self.click(whl_selector)
53-
self.click(tar_selector)
52+
self.click(whl_selector) # Download the "whl" file
53+
self.sleep(0.1)
54+
self.click(tar_selector) # Download the "tar" file
5455

5556
# Verify that the downloaded files appear in the [Downloads Folder]
5657
# (This only guarantees that the exact file name is in the folder.)

0 commit comments

Comments
 (0)