Skip to content

Commit b07e065

Browse files
authored
Merge pull request #651 from seleniumbase/improvements-to-safari-and-demo-mode
Improve Safari automation, Demo Mode, and Slow Mode
2 parents fe4394b + 8432695 commit b07e065

20 files changed

+298
-56
lines changed

docs/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
livereload==2.6.2;python_version>="3.6"
2+
pymdown-extensions==8.0
23
mkdocs==1.1.2
3-
mkdocs-material==5.5.3
4+
mkdocs-material==5.5.6
45
mkdocs-simple-hooks==0.1.1
56
mkdocs-material-extensions==1.0
67
mkdocs-minify-plugin==0.3.0

examples/basic_test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
"""
2-
Same as my_first_test.py, but without the asserts.
3-
"""
4-
51
from seleniumbase import BaseCase
62

73

@@ -10,7 +6,10 @@ class MyTestClass(BaseCase):
106
def test_basic(self):
117
self.open("https://store.xkcd.com/search")
128
self.type('input[name="q"]', "xkcd book\n")
9+
self.assert_text("xkcd book", "div.results")
1310
self.open("https://xkcd.com/353/")
1411
self.click('a[rel="license"]')
1512
self.go_back()
1613
self.click_link_text("About")
14+
self.click_link_text("comic #249")
15+
self.assert_element('img[alt*="Chess"]')

examples/my_first_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ class MyTestClass(BaseCase):
55

66
def test_basic(self):
77
self.open("https://store.xkcd.com/search")
8-
self.type('input[name="q"]', "xkcd book\n")
8+
self.type('input[name="q"]', "xkcd book")
9+
self.click('input[value="Search"]')
910
self.assert_text("xkcd: volume 0", "h3")
1011
self.open("https://xkcd.com/353/")
1112
self.assert_title("xkcd: Python")
@@ -15,6 +16,8 @@ def test_basic(self):
1516
self.go_back()
1617
self.click_link_text("About")
1718
self.assert_exact_text("xkcd.com", "h2")
19+
self.click_link_text("geohashing")
20+
self.assert_element("#comic img")
1821

1922
####
2023

examples/nth_child_test.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from seleniumbase import BaseCase
2+
3+
4+
class NthChildSelectorTests(BaseCase):
5+
6+
def test_locate_rows_with_colors(self):
7+
self.open("https://xkcd.com/color/rgb/")
8+
tbody = "center > table tbody"
9+
self.demo_mode = True
10+
self.highlight(tbody)
11+
self.post_message("Part 1: Assert text in given row.")
12+
self.assert_text("teal", "tr:nth-child(2)")
13+
self.assert_text("aqua", "tr:nth-child(4)")
14+
self.assert_text("mint", "tr:nth-child(14)")
15+
self.assert_text("jade", "tr:nth-child(36)")
16+
soup = self.get_beautiful_soup(self.get_page_source())
17+
self.post_message("Part 2: Find row with given text.")
18+
self.locate_first_row_with_color("rust", tbody, soup)
19+
self.locate_first_row_with_color("azure", tbody, soup)
20+
self.locate_first_row_with_color("topaz", tbody, soup)
21+
22+
def locate_first_row_with_color(self, color, tbody, soup):
23+
rows = soup.body.table.find_all("tr")
24+
num_rows = len(rows)
25+
for row in range(num_rows):
26+
row_selector = tbody + " tr:nth-child(%s)" % (row + 1)
27+
if color in rows[row].text:
28+
message = '"%s" found on row %s' % (color, row + 1)
29+
self.post_message_and_highlight(message, row_selector)
30+
return # Found row and done
31+
self.post_error_message(
32+
'"%s" could not be found on any row!' % color)

help_docs/method_summary.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ self.activate_messenger()
421421

422422
self.post_message(message, duration=None, pause=True, style="info")
423423

424+
self.post_message_and_highlight(message, selector, by=By.CSS_SELECTOR)
425+
424426
self.post_success_message(message, duration=None, pause=True)
425427

426428
self.post_error_message(message, duration=None, pause=True)

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
pip>=20.2.1
1+
pip>=20.2.2
22
packaging>=20.4
33
setuptools>=44.1.1;python_version<"3.5"
4-
setuptools>=49.3.1;python_version>="3.5"
4+
setuptools>=49.3.2;python_version>="3.5"
55
setuptools-scm>=4.1.2
66
wheel>=0.34.2
77
six==1.15.0

0 commit comments

Comments
 (0)