Skip to content

Commit a139f3b

Browse files
committed
Update example tests
1 parent f60ab9d commit a139f3b

5 files changed

+20
-13
lines changed

examples/rate_limiting_test.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
"""
2-
This test demonstrates the use of the "rate_limited" decorator.
3-
You can use this decorator on any method to rate-limit it.
4-
"""
1+
""" This test demonstrates the use of the "rate_limited" decorator.
2+
You can use this decorator on any method to rate-limit it. """
53

64
from seleniumbase import BaseCase
75
from seleniumbase import decorators

examples/test_chinese_pdf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
class ChinesePdfTests(BaseCase):
66
def test_chinese_pdf(self):
7+
self.open("data:,")
78
pdf = "https://seleniumbase.io/cdn/pdf/unittest_zh.pdf"
89

910
# Get and print PDF text
1011
pdf_text = self.get_pdf_text(pdf, page=2)
11-
print("\n" + pdf_text)
12+
self._print("\n" + pdf_text)
1213

1314
# Assert PDF contains the expected text on Page 2
1415
self.assert_pdf_text(pdf, "个测试类", page=2)

examples/test_get_pdf_text.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
class PdfTests(BaseCase):
55
def test_get_pdf_text(self):
6+
self.open("data:,")
67
pdf = (
78
"https://nostarch.com/download/"
89
"Automate_the_Boring_Stuff_sample_ch17.pdf"
910
)
1011
pdf_text = self.get_pdf_text(pdf, page=1)
11-
print("\n" + pdf_text)
12+
self._print("\n" + pdf_text)

examples/test_pdf_asserts.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
class PdfAssertTests(BaseCase):
55
def test_assert_pdf_text(self):
6+
self.open("data:,")
67
# Assert PDF contains the expected text on Page 1
78
self.assert_pdf_text(
89
"https://nostarch.com/download/Automate_the_Boring_Stuff_dTOC.pdf",

examples/test_scrape_bing.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ def test_scrape_bing(self):
77
self.wait_for_element("main h2 a")
88
soup = self.get_beautiful_soup()
99
titles = [item.text for item in soup.select("main h2 a")]
10-
print("\nSearch Result Headers:")
10+
self._print("\nSearch Result Headers:")
1111
for title in titles:
12-
if "seleniumbase/" in title.lower():
13-
print(" " + title)
12+
if (
13+
"seleniumbase/" in title.lower()
14+
or "SeleniumBase Docs" in title
15+
):
16+
self._print(" " + title)
1417
links = [item["href"] for item in soup.select("main h2 a")]
15-
print("Search Result Links:")
18+
self._print("Search Result Links:")
1619
for link in links:
17-
if "github.com/seleniumbase" in link.lower():
18-
print(" " + link)
20+
if (
21+
"github.com/seleniumbase" in link.lower()
22+
or "https://seleniumbase.io/" in link.lower()
23+
):
24+
self._print(" " + link)
1925
self.click_if_visible('a[href="https://github.com/seleniumbase"]')
20-
print("Last Page = " + self.get_current_url())
26+
self._print("Last Page = " + self.get_current_url())

0 commit comments

Comments
 (0)