Skip to content

Commit 9e10600

Browse files
authored
Merge pull request #1759 from seleniumbase/major-upgrades
Lots of updates / Recorder Mode upgrade
2 parents b023adf + 4aa88f1 commit 9e10600

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2467
-1225
lines changed

examples/coffee_cart_tests.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Use SeleniumBase to test the Coffee Cart App."""
2+
from parameterized import parameterized
23
from seleniumbase import BaseCase
34
BaseCase.main(__name__, __file__)
45

@@ -25,7 +26,8 @@ def test_buy_one_cappuccino(self):
2526
self.assert_exact_text("cart (0)", 'a[aria-label="Cart page"]')
2627
self.assert_exact_text("Total: $0.00", 'button[data-test="checkout"]')
2728

28-
def test_coffee_promo_with_preview(self):
29+
@parameterized.expand([[False], [True]])
30+
def test_coffee_promo_with_preview(self, accept_promo):
2931
self.open("https://seleniumbase.io/coffee/")
3032
self.click('div[data-test="Espresso"]')
3133
self.click('div[data-test="Americano"]')
@@ -35,15 +37,23 @@ def test_coffee_promo_with_preview(self):
3537
total_string = "Total: $33.00"
3638
if self.is_element_visible("div.promo"):
3739
self.assert_text("Get an extra cup of Mocha for $4.", "div.promo")
38-
self.click("div.promo button.yes")
39-
self.assert_exact_text("cart (4)", 'a[aria-label="Cart page"]')
40-
promo = True
41-
total_string = "Total: $37.00"
42-
self.hover('button[data-test="checkout"]')
40+
if accept_promo:
41+
self.click("div.promo button.yes")
42+
self.assert_exact_text("cart (4)", 'a[aria-label="Cart page"]')
43+
promo = True
44+
total_string = "Total: $37.00"
45+
else:
46+
self.click("div.promo button.no")
47+
checkout_button = 'button[data-test="checkout"]'
4348
if promo:
49+
self.hover(checkout_button)
50+
if not self.is_element_visible("ul.cart-preview"):
51+
self.highlight(checkout_button)
52+
self.post_message("STOP moving the mouse!<br />Hover blocked!")
53+
self.hover(checkout_button)
4454
self.assert_text("(Discounted) Mocha", "ul.cart-preview")
45-
self.assert_exact_text(total_string, 'button[data-test="checkout"]')
46-
self.click('button[data-test="checkout"]')
55+
self.assert_exact_text(total_string, checkout_button)
56+
self.click(checkout_button)
4757
self.type("input#name", "Selenium Coffee")
4858
self.type("input#email", "[email protected]")
4959
self.click("button#submit-payment")

examples/edge_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
class EdgeTests(BaseCase):
1010
def test_edge(self):
1111
if self.browser != "edge":
12-
self.open("data:,")
12+
self.open("about:blank")
1313
print("\n This test is only for Microsoft Edge (Chromium)!")
1414
print(' (Run this test using "--edge" or "--browser=edge")')
1515
self.skip('Use "--edge" or "--browser=edge"')
1616
if self.headless:
17-
self.open("data:,")
17+
self.open("about:blank")
1818
print("\n This test is NOT designed for Headless Mode!")
1919
self.skip('Do NOT use "--headless" with this test!')
2020
self.open("edge://settings/help")

examples/hack_the_planet.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_all_your_base_are_belong_to_us(self):
4343
self.set_text_content('#shelf-1 a[href*="airtag"]', "TO")
4444
self.set_text_content('#shelf-1 a[href*="tv"]', "US")
4545
self.set_text_content('#shelf-1 a[href*="homepod"]', ".")
46-
self.set_text_content("h2", aybabtu + ". ")
46+
self.set_text_content("#shelf-3 h2", aybabtu + ". ")
4747
self.highlight("div.rs-shop-subheader", loops=6, scroll=False)
4848
self.highlight("#shelf-1", loops=2, scroll=False)
4949
self.highlight('#shelf-1 a[href*="mac"]', loops=1, scroll=False)
@@ -53,7 +53,7 @@ def test_all_your_base_are_belong_to_us(self):
5353
self.highlight('#shelf-1 a[href*="airpod"]', loops=1, scroll=False)
5454
self.highlight('#shelf-1 a[href*="airtag"]', loops=1, scroll=False)
5555
self.highlight('#shelf-1 a[href*="tv"]', loops=3, scroll=False)
56-
self.highlight("h2", loops=9, scroll=False)
56+
self.highlight("#shelf-3 h2", loops=9, scroll=False)
5757

5858
self.open("https://google.com/ncr")
5959
self.hide_elements("iframe")
@@ -240,11 +240,11 @@ def test_all_your_base_are_belong_to_us(self):
240240
self.set_text_content('li a:contains("Support")', "BELONG")
241241
self.set_text_content('li a:contains("Blog")', "TO")
242242
self.set_text_content('li a:contains("English")', "US")
243-
self.set_text_content("div.lead", aybabtu)
243+
self.set_text_content("div.mx-auto p", aybabtu)
244244
self.set_text_content("h2", aybabtu)
245245
if self.is_element_visible('button[data-dismiss="alert"] span'):
246246
self.js_click('button[data-dismiss="alert"] span', scroll=False)
247-
zoom_in = "div.lead{zoom: 1.25;-moz-transform: scale(1.25);}"
247+
zoom_in = "div.mx-auto p{zoom: 1.1;-moz-transform: scale(1.1);}"
248248
self.add_css_style(zoom_in)
249249
self.highlight("div#main_navbar", loops=1, scroll=False)
250250
self.highlight('li a:contains("ALL")', loops=1, scroll=False)
@@ -254,7 +254,7 @@ def test_all_your_base_are_belong_to_us(self):
254254
self.highlight('li a:contains("BELONG")', loops=1, scroll=False)
255255
self.highlight('li a:contains("TO")', loops=1, scroll=False)
256256
self.highlight('li a:contains("US")', loops=2, scroll=False)
257-
self.highlight("div.lead", loops=6, scroll=False)
257+
self.highlight("div.mx-auto p", loops=6, scroll=False)
258258
self.highlight("h2", loops=8, scroll=False)
259259

260260
self.open("https://www.python.org/")
@@ -284,6 +284,8 @@ def test_all_your_base_are_belong_to_us(self):
284284
self.set_text_content('a[title="Plans & Pricing"]', aybabtu)
285285
self.set_text_content('a[title="Get Started"]', ayb)
286286
self.set_text_content("p.no-widows", aybabtu)
287+
zoom_out = "h1{zoom: 0.8;-moz-transform: scale(0.8);}"
288+
self.add_css_style(zoom_out)
287289
self.set_text_content("h1.no-widows", aybabtu)
288290
self.set_text_content("a#lpc-button", "Automate with SeleniumBase")
289291
self.highlight('a[title="Plans & Pricing"]', loops=6, scroll=False)
@@ -308,7 +310,6 @@ def test_all_your_base_are_belong_to_us(self):
308310
self.set_text_content('a[href*="jira/pricing"]', ayb)
309311
self.set_text_content('a[href*="jira/enterprise"]', abtu)
310312
self.set_text_content('a[href="/software/jira/features"]', "")
311-
self.set_text_content('a[href="/software/jira/guides"]', "")
312313
self.set_text_content("h1", aybabtu)
313314
self.highlight("ul.imkt-navbar__link-list", loops=2, scroll=False)
314315
self.highlight('a[href*="jira/pricing"]', loops=3, scroll=False)

examples/master_qa/pytest.ini

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

3-
# Display console output, disable cacheprovider:
4-
addopts = --capture=no -p no:cacheprovider
3+
# Display console output, disable cacheprovider, don't collect recordings:
4+
addopts = --capture=no -p no:cacheprovider --ignore=recordings
5+
6+
# Skip looking in these directories for tests:
7+
norecursedirs = .* build dist recordings temp
58

69
# Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning
710
filterwarnings =
@@ -18,7 +21,8 @@ python_files = test_*.py *_test.py *_tests.py *_suite.py *_test_*.py
1821
python_classes = Test* *Test* *Test *Tests *Suite
1922
python_functions = test_*
2023

21-
# Here are the pytest markers used in the example tests:
24+
# Here are some common pytest markers:
25+
# (Some are used in the example tests.)
2226
# (pytest v4.5.0 and newer requires marker registration to prevent warnings.)
2327
# (Future versions of pytest may turn those marker warnings into errors.)
2428
markers =
@@ -32,7 +36,11 @@ markers =
3236
offline: custom marker
3337
develop: custom marker
3438
qa: custom marker
39+
ci: custom marker
40+
e2e: custom marker
3541
ready: custom marker
42+
smoke: custom marker
43+
deploy: custom marker
3644
active: custom marker
3745
master: custom marker
3846
release: custom marker
Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,48 @@
11
[pytest]
22

3-
# Display console output, disable cacheprovider:
4-
addopts = --capture=no -p no:cacheprovider
3+
# Display console output, disable cacheprovider, don't collect recordings:
4+
addopts = --capture=no -p no:cacheprovider --ignore=recordings
5+
6+
# Skip looking in these directories for tests:
7+
norecursedirs = .* build dist recordings temp
58

69
# Ignore warnings such as DeprecationWarning and PytestUnknownMarkWarning
710
filterwarnings =
811
ignore::pytest.PytestWarning
912
ignore:.*U.*mode is deprecated:DeprecationWarning
1013

14+
# Configure the junit_family option explicitly:
15+
junit_family = legacy
16+
1117
# Set pytest discovery rules:
1218
# (Most of the rules here are similar to the default rules.)
1319
# (unittest.TestCase rules override the rules here for classes and functions.)
1420
python_files = *.py
21+
python_classes = Test* *Test* *Test *Tests *Suite
1522
python_functions = test_*
23+
24+
# Here are some common pytest markers:
25+
# (Some are used in the example tests.)
26+
# (pytest v4.5.0 and newer requires marker registration to prevent warnings.)
27+
# (Future versions of pytest may turn those marker warnings into errors.)
28+
markers =
29+
marker1: custom marker
30+
marker2: custom marker
31+
marker3: custom marker
32+
marker_test_suite: custom marker
33+
expected_failure: custom marker
34+
local: custom marker
35+
remote: custom marker
36+
offline: custom marker
37+
develop: custom marker
38+
qa: custom marker
39+
ci: custom marker
40+
e2e: custom marker
41+
ready: custom marker
42+
smoke: custom marker
43+
deploy: custom marker
44+
active: custom marker
45+
master: custom marker
46+
release: custom marker
47+
staging: custom marker
48+
production: custom marker

examples/offline_examples/test_demo_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class OfflineTests(BaseCase):
99
def test_demo_page(self):
1010
# Load a local html file into the web browser
1111
dir_path = os.path.dirname(os.path.abspath(__file__))
12-
file_path = dir_path + "/demo_page.html"
12+
file_path = os.path.join(dir_path, "demo_page.html")
1313
self.load_html_file(file_path)
1414

1515
# Assert the title of the current web page

examples/parameterized_test.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
class SearchTests(BaseCase):
77
@parameterized.expand(
88
[
9-
["site:Python.org Download", "Download Python", "img.python-logo"],
10-
["site:SeleniumBase.io", "SeleniumBase", 'img[alt*="SeleniumB"]'],
11-
["site:Wikipedia.org", "Wikipedia", "img.central-featured-logo"],
9+
["SeleniumBase Commander", "Commander", "GUI / Commander"],
10+
["SeleniumBase Recorder", "Recorder", "Recorder Mode"],
11+
["SeleniumBase Syntax", "Syntax", "Syntax Formats"],
1212
]
1313
)
14-
def test_parameterized_search(self, search_key, expected_text, img):
15-
self.open("https://duckduckgo.com/")
16-
self.type('input[name="q"]', search_key + "\n")
17-
self.assert_text(expected_text, "div.results")
18-
self.click('a:contains("%s")' % expected_text)
19-
self.assert_element(img)
14+
def test_parameterized_search(self, search_term, keyword, title_text):
15+
self.open("https://seleniumbase.io/help_docs/how_it_works/")
16+
self.type('input[aria-label="Search"]', search_term)
17+
self.click('mark:contains("%s")' % keyword)
18+
self.assert_title_contains(title_text)

examples/performance_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def my_method():
3030
class PerformanceClass(BaseCase):
3131
@decorators.print_runtime("Open Swag Labs and Log In")
3232
def login_to_swag_labs(self):
33+
print()
3334
with decorators.print_runtime("Open Swag Labs"):
3435
self.open("https://www.saucedemo.com")
3536
self.type("#user-name", "standard_user")

0 commit comments

Comments
 (0)