Skip to content

Commit f3b01ee

Browse files
authored
Merge pull request #1202 from seleniumbase/pytest-7.0.0-has-arrived
pytest 7 has arrived
2 parents 04a8ab9 + 3fe1ace commit f3b01ee

File tree

12 files changed

+127
-64
lines changed

12 files changed

+127
-64
lines changed

examples/test_chinese_pdf.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
class ChinesePdfTests(BaseCase):
66
def test_chinese_pdf(self):
7-
8-
pdf = (
9-
"https://github.com/seleniumbase/SeleniumBase/"
10-
"files/3895614/unittest.pdf"
11-
)
7+
pdf = "https://seleniumbase.io/cdn/pdf/unittest_zh.pdf"
128

139
# Get and print PDF text
1410
pdf_text = self.get_pdf_text(pdf, page=2)

examples/unit_tests/verify_framework.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,48 @@ def test_request_sb_fixture(request):
8989
assert result.matchreport("test_request_sb_fixture").passed
9090

9191

92+
def check_outcome_field(outcomes, field_name, expected_value):
93+
field_value = outcomes.get(field_name, 0)
94+
assert field_value == expected_value, (
95+
"outcomes.%s has an unexpected value! "
96+
'Expected "%s" but got "%s"!'
97+
% (field_name, expected_value, field_value)
98+
)
99+
100+
101+
def assert_outcomes(
102+
result,
103+
passed=1,
104+
skipped=0,
105+
failed=0,
106+
xfailed=0,
107+
xpassed=0,
108+
rerun=0,
109+
):
110+
outcomes = result.parseoutcomes()
111+
check_outcome_field(outcomes, "passed", passed)
112+
check_outcome_field(outcomes, "skipped", skipped)
113+
check_outcome_field(outcomes, "failed", failed)
114+
check_outcome_field(outcomes, "xfailed", xfailed)
115+
check_outcome_field(outcomes, "xpassed", xpassed)
116+
check_outcome_field(outcomes, "rerun", rerun)
117+
118+
119+
def test_rerun_failures(testdir):
120+
testdir.makepyfile(
121+
"""
122+
from seleniumbase import BaseCase
123+
class MyTestCase(BaseCase):
124+
def test_passing(self):
125+
self.assert_equal('yes', 'yes')
126+
def test_failing(self):
127+
self.assert_equal('yes', 'no')
128+
"""
129+
)
130+
result = testdir.runpytest("--headless", "--reruns=1", "--rs", "-v")
131+
assert_outcomes(result, passed=1, failed=1, rerun=1)
132+
133+
92134
def test_browser_launcher(testdir):
93135
testdir.makepyfile(
94136
"""

examples/wordle_test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ class WordleTests(BaseCase):
1010
word_list = []
1111

1212
def initalize_word_list(self):
13-
js_file = "https://www.powerlanguage.co.uk/wordle/main.e65ce0a5.js"
14-
req_text = requests.get(js_file).text
15-
start = req_text.find("var La=") + len("var La=")
16-
end = req_text.find("],", start) + 1
17-
word_string = req_text[start:end]
13+
txt_file = "https://seleniumbase.io/cdn/txt/wordle_words.txt"
14+
word_string = requests.get(txt_file).text
1815
self.word_list = ast.literal_eval(word_string)
1916

2017
def modify_word_list(self, word, letter_status):

examples/youtube_search_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
class YouTubeSearchTests(BaseCase):
55
def test_youtube_autocomplete_results(self):
66
""" Verify YouTube autocomplete search results. """
7-
self.get_new_driver(block_images=True) # Runs faster
8-
self.open("https://www.youtube.com/")
7+
self.open("https://www.youtube.com/c/MichaelMintz")
98
search_term = "seleniumbase"
109
search_selector = "input#search"
1110
result_selector = 'li[role="presentation"] b'
@@ -25,8 +24,7 @@ def test_youtube_autocomplete_results(self):
2524

2625
def test_youtube_search_results(self):
2726
""" Verify finding a specific video by performing a YouTube search. """
28-
self.get_new_driver(block_images=True) # Runs faster
29-
self.open("https://www.youtube.com/")
27+
self.open("https://www.youtube.com/c/MichaelMintz")
3028
search_term = "SeleniumBase Common API Methods"
3129
search_selector = "input#search"
3230
self.type(search_selector, search_term + "\n")

help_docs/useful_grep_commands.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ OR
1212

1313
--------
1414

15-
#### Replace all occurrences of "foo_abc" with "bar_xyz" on Linux, from the current directory:
15+
#### Replace all occurrences of "foo_abc" with "bar_xyz" on Linux, for Python files from the current directory:
1616

17-
``sed -i 's/foo_abc/bar_xyz/g' *``
17+
``sed -i 's/foo_abc/bar_xyz/g' *.py``
1818

19-
#### Replace all occurrences of "foo_abc" with "bar_xyz" on macOS (file-backup required), from the current directory:
19+
#### Replace all occurrences of "foo_abc" with "bar_xyz" on macOS, for Python files from the current directory:
2020

21-
``sed -i '.bak' 's/foo_abc/bar_xyz/g' *``
21+
``sed -i '' 's/foo_abc/bar_xyz/g' *.py``
2222

2323
--------
2424

integrations/node_js/my_first_test.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22

33

44
class MyTestClass(BaseCase):
5-
def test_basics(self):
6-
url = "https://store.xkcd.com/collections/posters"
7-
self.open(url)
8-
self.type('input[name="q"]', "xkcd book")
9-
self.click('input[value="Search"]')
10-
self.assert_text("xkcd: volume 0", "h3")
11-
self.open("https://xkcd.com/353/")
12-
self.assert_title("xkcd: Python")
13-
self.assert_element('img[alt="Python"]')
14-
self.click('a[rel="license"]')
15-
self.assert_text("free to copy and reuse")
16-
self.go_back()
17-
self.click_link("About")
18-
self.assert_exact_text("xkcd.com", "h2")
5+
def test_swag_labs(self):
6+
self.open("https://www.saucedemo.com")
7+
self.type("#user-name", "standard_user")
8+
self.type("#password", "secret_sauce\n")
9+
self.assert_element("#inventory_container")
10+
self.assert_text("PRODUCTS", "span.title")
11+
self.click('button[name*="backpack"]')
12+
self.click("#shopping_cart_container a")
13+
self.assert_text("YOUR CART", "span.title")
14+
self.assert_text("Backpack", "div.cart_item")
15+
self.click("button#checkout")
16+
self.type("#first-name", "SeleniumBase")
17+
self.type("#last-name", "Automation")
18+
self.type("#postal-code", "77123")
19+
self.click("input#continue")
20+
self.assert_text("CHECKOUT: OVERVIEW")
21+
self.assert_text("Backpack", "div.cart_item")
22+
self.click("button#finish")
23+
self.assert_exact_text("THANK YOU FOR YOUR ORDER", "h2")
24+
self.assert_element('img[alt="Pony Express"]')
25+
self.js_click("a#logout_sidebar_link")

integrations/node_js/test_demo_site.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from seleniumbase import BaseCase
22

33

4-
class MyTestClass(BaseCase):
4+
class DemoSiteTests(BaseCase):
55
def test_demo_site(self):
66
self.open("https://seleniumbase.io/demo_page")
77

@@ -21,12 +21,17 @@ def test_demo_site(self):
2121

2222
# Verify that a hover dropdown link changes page text
2323
self.assert_text("Automation Practice", "h3")
24-
self.hover_and_click("#myDropdown", "#dropOption2")
24+
try:
25+
self.hover_and_click(
26+
"#myDropdown", "#dropOption2", timeout=2)
27+
except Exception:
28+
# If a human moves the mouse while the test runs
29+
self.js_click("#dropOption2")
2530
self.assert_text("Link Two Selected", "h3")
2631

2732
# Verify that a button click changes text on the page
2833
self.assert_text("This Text is Green", "#pText")
29-
self.click("#myButton")
34+
self.click('button:contains("Click Me")')
3035
self.assert_text("This Text is Purple", "#pText")
3136

3237
# Assert that the given SVG is visible on the page
@@ -60,9 +65,11 @@ def test_demo_site(self):
6065
self.assert_true(self.is_selected("#radioButton2"))
6166

6267
# Verify that clicking a checkbox makes it selected
68+
self.assert_element_not_visible("img#logo")
6369
self.assert_false(self.is_selected("#checkBox1"))
6470
self.click("#checkBox1")
6571
self.assert_true(self.is_selected("#checkBox1"))
72+
self.assert_element("img#logo")
6673

6774
# Verify clicking on multiple elements with one call
6875
self.assert_false(self.is_selected("#checkBox2"))
@@ -82,6 +89,11 @@ def test_demo_site(self):
8289
self.assert_true(self.is_selected(".fBox"))
8390
self.switch_to_default_content()
8491

92+
# Verify Drag and Drop
93+
self.assert_element_not_visible("div#drop2 img#logo")
94+
self.drag_and_drop("img#logo", "div#drop2")
95+
self.assert_element("div#drop2 img#logo")
96+
8597
# Assert link text
8698
self.assert_link_text("seleniumbase.com")
8799
self.assert_link_text("SeleniumBase on GitHub")
@@ -93,8 +105,16 @@ def test_demo_site(self):
93105
# Assert exact text
94106
self.assert_exact_text("Demo Page", "h1")
95107

108+
# Highlight a page element (Also asserts visibility)
109+
self.highlight("h2")
110+
111+
# Actions with Demo Mode enabled
112+
self.demo_mode = True
113+
self.type("input", "Have a Nice Day!")
114+
self.assert_text("SeleniumBase", "h2")
115+
96116
# Assert no broken links (Can be slow if many links)
97117
# self.assert_no_404_errors()
98118

99119
# Assert no JavaScript errors (Can also detect 404s)
100-
self.assert_no_js_errors()
120+
# self.assert_no_js_errors()

mkdocs_build/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ docutils==0.18.1
44
python-dateutil==2.8.2
55
livereload==2.6.3;python_version>="3.6"
66
joblib==1.1.0;python_version>="3.6"
7-
Markdown==3.3.6;python_version>="3.6"
7+
Markdown==3.2.2;python_version>="3.6" and python_version<"3.7"
8+
Markdown==3.3.6;python_version>="3.7"
89
MarkupSafe==2.0.1;python_version>="3.6"
910
pyparsing==3.0.7;python_version>="3.6"
1011
keyring==23.5.0;python_version>="3.7"

requirements.txt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ setuptools>=59.6.0;python_version>="3.6" and python_version<"3.7"
99
setuptools>=60.7.1;python_version>="3.7"
1010
setuptools-scm>=5.0.2;python_version<"3.6"
1111
setuptools-scm>=6.4.2;python_version>="3.6"
12-
tomli>=1.2.2;python_version>="3.6" and python_version<"3.7"
12+
tomli>=1.2.3;python_version>="3.6" and python_version<"3.7"
1313
tomli>=2.0.0;python_version>="3.7"
1414
wheel>=0.37.1
1515
attrs>=21.4.0
@@ -30,7 +30,7 @@ chardet==3.0.4;python_version<"3.5"
3030
chardet==4.0.0;python_version>="3.5"
3131
charset-normalizer==2.0.11;python_version>="3.5"
3232
urllib3==1.26.8
33-
requests==2.27.0;python_version<"3.5"
33+
requests==2.27.1;python_version<"3.5"
3434
requests==2.25.1;python_version>="3.5" and python_version<"3.6"
3535
requests==2.27.1;python_version>="3.6"
3636
nose==1.3.7
@@ -60,7 +60,7 @@ py==1.8.1;python_version<"3.5"
6060
py==1.11.0;python_version>="3.5"
6161
pytest==4.6.11;python_version<"3.5"
6262
pytest==6.1.2;python_version>="3.5" and python_version<"3.6"
63-
pytest==6.2.5;python_version>="3.6"
63+
pytest==7.0.0;python_version>="3.6"
6464
pytest-forked==1.3.0;python_version<"3.6"
6565
pytest-forked==1.4.0;python_version>="3.6"
6666
pytest-html==1.22.1;python_version<"3.6"
@@ -83,13 +83,12 @@ beautifulsoup4==4.9.3;python_version<"3.5"
8383
beautifulsoup4==4.10.0;python_version>="3.5"
8484
cryptography==2.9.2;python_version<"3.5"
8585
cryptography==3.2.1;python_version>="3.5" and python_version<"3.6"
86-
cryptography==3.4.8;python_version>="3.6" and python_version<"3.7"
87-
cryptography==36.0.1;python_version>="3.7"
86+
cryptography==36.0.1;python_version>="3.6"
8887
pygments==2.5.2;python_version<"3.5"
8988
pygments==2.11.2;python_version>="3.5"
9089
prompt-toolkit==1.0.18;python_version<"3.5"
91-
prompt-toolkit==2.0.10;python_version>="3.5" and python_version<"3.6.2"
92-
prompt-toolkit==3.0.26;python_version>="3.6.2"
90+
prompt-toolkit==2.0.10;python_version>="3.5" and python_version<"3.6"
91+
prompt-toolkit==3.0.26;python_version>="3.6"
9392
decorator==4.4.2;python_version<"3.5"
9493
decorator==5.1.1;python_version>="3.5"
9594
ipython==5.10.0;python_version<"3.5"
@@ -101,10 +100,10 @@ colorama==0.4.4
101100
platformdirs==2.0.2;python_version<"3.6"
102101
platformdirs==2.4.0;python_version>="3.6" and python_version<"3.7"
103102
platformdirs==2.4.1;python_version>="3.7"
104-
pathlib2==2.3.5;python_version<"3.5"
105-
importlib-metadata==2.0.0;python_version<"3.5"
106-
importlib-metadata==2.1.1;python_version>="3.5" and python_version<"3.6"
107-
virtualenv>=20.13.0
103+
pathlib2==2.3.6;python_version<"3.5"
104+
importlib-metadata==2.1.3;python_version<"3.6"
105+
importlib-metadata==4.2.0;python_version>="3.6" and python_version<"3.8"
106+
virtualenv>=20.13.1
108107
pycparser==2.21
109108
pymysql==0.10.1;python_version<"3.6"
110109
pymysql==1.0.2;python_version>="3.6"
@@ -119,7 +118,7 @@ Pillow==8.4.0;python_version>="3.6" and python_version<"3.7"
119118
Pillow==9.0.1;python_version>="3.7"
120119
typing-extensions==3.10.0.2;python_version<"3.6"
121120
typing-extensions==4.0.0;python_version>="3.6" and python_version<"3.8"
122-
rich==11.1.0;python_version>="3.6.2" and python_version<"4.0"
121+
rich==11.1.0;python_version>="3.6" and python_version<"4.0"
123122
tornado==5.1.1;python_version<"3.5"
124123
tornado==6.1;python_version>="3.5"
125124
pdfminer.six==20191110;python_version<"3.5"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "2.4.7"
2+
__version__ = "2.4.8"

0 commit comments

Comments
 (0)