Skip to content

Commit 4fe0dc7

Browse files
authored
Merge pull request #545 from seleniumbase/multiple-updates
Multiple Updates
2 parents c47cf81 + 7be9655 commit 4fe0dc7

File tree

24 files changed

+219
-20
lines changed

24 files changed

+219
-20
lines changed

.github/workflows/python-package.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ jobs:
4848
- name: Run pytest boilerplate_test.py --browser=chrome --headless
4949
run: |
5050
pytest examples/boilerplates/boilerplate_test.py --browser=chrome --headless -v -s --junit-xml=junit/test-results.xml
51+
- name: Run pytest test_demo_site.py --browser=chrome --headless
52+
run: |
53+
pytest examples/test_demo_site.py --browser=chrome --headless -v -s --junit-xml=junit/test-results.xml
5154
- name: Run pytest my_first_test.py --browser=chrome --headless
5255
run: |
5356
pytest examples/my_first_test.py --browser=chrome --headless -v -s --junit-xml=junit/test-results.xml

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ SeleniumBase provides additional Pytest command-line options for tests:
215215
--settings-file=FILE # (Overrides SeleniumBase settings.py values.)
216216
--env=ENV # (Set a test environment. Use "self.env" to use this in tests.)
217217
--data=DATA # (Extra data to pass to tests. Use "self.data" in tests.)
218+
--var1=DATA # (Extra data to pass to tests. Use "self.var1" in tests.)
219+
--var2=DATA # (Extra data to pass to tests. Use "self.var2" in tests.)
220+
--var3=DATA # (Extra data to pass to tests. Use "self.var3" in tests.)
218221
--user-data-dir=DIR # (Set the Chrome user data directory to use.)
219222
--server=SERVER # (The server / IP address used by the tests.)
220223
--port=PORT # (The port that's used by the test server.)

examples/basic_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ def test_basic(self):
1212
self.click('a[rel="license"]')
1313
self.go_back()
1414
self.click("link=About")
15-
self.open("https://store.xkcd.com/collections/everything")
15+
self.open("://store.xkcd.com/collections/everything")
1616
self.update_text("input.search-input", "xkcd book\n")

examples/my_first_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_basic(self):
1212
self.go_back()
1313
self.click("link=About")
1414
self.assert_text("xkcd.com", "h2")
15-
self.open("https://store.xkcd.com/collections/everything")
15+
self.open("://store.xkcd.com/collections/everything")
1616
self.update_text("input.search-input", "xkcd book\n")
1717
self.assert_exact_text("xkcd: volume 0", "h3")
1818

examples/offline_examples/test_demo_page.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import pytest
12
from seleniumbase import BaseCase
23

34

4-
class MyTestClass(BaseCase):
5+
@pytest.mark.offline # Can be run with: "pytest -m offline"
6+
class OfflineTestClass(BaseCase):
57

68
def test_demo_page(self):
79
# Load a local html file into the browser
@@ -53,15 +55,24 @@ def test_demo_page(self):
5355
self.assert_true(self.is_text_visible("Frame Text"))
5456
self.switch_to_default_content()
5557

58+
# Verify that clicking a radio button selects it
59+
self.assert_false(self.is_selected("#radioButton2"))
60+
self.click("#radioButton2")
61+
self.assert_true(self.is_selected("#radioButton2"))
62+
5663
# Verify that clicking a checkbox makes it selected
5764
self.assert_false(self.is_selected("#checkBox1"))
5865
self.click("#checkBox1")
5966
self.assert_true(self.is_selected("#checkBox1"))
6067

61-
# Verify that clicking a radio button selects it
62-
self.assert_false(self.is_selected("#radioButton2"))
63-
self.click("#radioButton2")
64-
self.assert_true(self.is_selected("#radioButton2"))
68+
# Verify clicking on multiple elements with one call
69+
self.assert_false(self.is_selected("#checkBox2"))
70+
self.assert_false(self.is_selected("#checkBox3"))
71+
self.assert_false(self.is_selected("#checkBox4"))
72+
self.click_visible_elements("input.checkBoxClassB")
73+
self.assert_true(self.is_selected("#checkBox2"))
74+
self.assert_true(self.is_selected("#checkBox3"))
75+
self.assert_true(self.is_selected("#checkBox4"))
6576

6677
# Assert the title of the current web page
6778
self.assert_title("Web Testing Page")

examples/test_demo_site.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from seleniumbase import BaseCase
2+
3+
4+
class MyTestClass(BaseCase):
5+
6+
def test_demo_site(self):
7+
self.open("://seleniumbase.github.io/demo_page.html")
8+
9+
# Assert that the element is visible on the page
10+
self.assert_element("tbody#tbodyId")
11+
12+
# Assert that the text appears within a given element
13+
self.assert_text("Demo Page", "h1")
14+
15+
# Update the text of various text fields on the page
16+
self.update_text("#myTextInput", "This is Automated")
17+
self.update_text("textarea.area1", "Testing Time!\n")
18+
self.update_text('[name="preText2"]', "Typing Text!")
19+
20+
# Verify that a hover dropdown link changes page text
21+
self.assert_text("Automation Practice", "h3")
22+
self.hover_and_click("#myDropdown", "#dropOption2")
23+
self.assert_text("Link Two Selected", "h3")
24+
25+
# Verify that a button click changes text on the page
26+
self.assert_text("This Text is Green", "#pText")
27+
self.click("#myButton")
28+
self.assert_text("This Text is Purple", "#pText")
29+
30+
# Assert that the given SVG is visible on the page
31+
self.assert_element('svg[name="svgName"]')
32+
33+
# Verify that a slider control updates a progrss bar
34+
self.assert_element('progress[value="50"]')
35+
self.press_right_arrow("#myslider", times=5)
36+
self.assert_element('progress[value="100"]')
37+
38+
# Verify that a "select" option updates a meter bar
39+
self.assert_element('meter[value="0.25"]')
40+
self.select_option_by_text("#mySelect", "Set to 75%")
41+
self.assert_element('meter[value="0.75"]')
42+
43+
# Assert an element located inside an iFrame
44+
self.assert_false(self.is_element_visible("img"))
45+
self.switch_to_frame("#myFrame1")
46+
self.assert_true(self.is_element_visible("img"))
47+
self.switch_to_default_content()
48+
49+
# Assert text located inside an iFrame
50+
self.assert_false(self.is_text_visible("Frame Text"))
51+
self.switch_to_frame("#myFrame2")
52+
self.assert_true(self.is_text_visible("Frame Text"))
53+
self.switch_to_default_content()
54+
55+
# Verify that clicking a radio button selects it
56+
self.assert_false(self.is_selected("#radioButton2"))
57+
self.click("#radioButton2")
58+
self.assert_true(self.is_selected("#radioButton2"))
59+
60+
# Verify that clicking a checkbox makes it selected
61+
self.assert_false(self.is_selected("#checkBox1"))
62+
self.click("#checkBox1")
63+
self.assert_true(self.is_selected("#checkBox1"))
64+
65+
# Verify clicking on multiple elements with one call
66+
self.assert_false(self.is_selected("#checkBox2"))
67+
self.assert_false(self.is_selected("#checkBox3"))
68+
self.assert_false(self.is_selected("#checkBox4"))
69+
self.click_visible_elements("input.checkBoxClassB")
70+
self.assert_true(self.is_selected("#checkBox2"))
71+
self.assert_true(self.is_selected("#checkBox3"))
72+
self.assert_true(self.is_selected("#checkBox4"))
73+
74+
# Assert the title of the current web page
75+
self.assert_title("Web Testing Page")

help_docs/customizing_test_runs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ SeleniumBase provides additional Pytest command-line options for tests:
8888
--settings-file=FILE # (Overrides SeleniumBase settings.py values.)
8989
--env=ENV # (Set a test environment. Use "self.env" to use this in tests.)
9090
--data=DATA # (Extra data to pass to tests. Use "self.data" in tests.)
91+
--var1=DATA # (Extra data to pass to tests. Use "self.var1" in tests.)
92+
--var2=DATA # (Extra data to pass to tests. Use "self.var2" in tests.)
93+
--var3=DATA # (Extra data to pass to tests. Use "self.var3" in tests.)
9194
--user-data-dir=DIR # (Set the Chrome user data directory to use.)
9295
--server=SERVER # (The server / IP address used by the tests.)
9396
--port=PORT # (The port that's used by the test server.)

integrations/node_js/my_first_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ def test_basic(self):
1212
self.go_back()
1313
self.click("link=About")
1414
self.assert_text("xkcd.com", "h2")
15-
self.open("https://store.xkcd.com/collections/everything")
15+
self.open("://store.xkcd.com/collections/everything")
1616
self.update_text("input.search-input", "xkcd book\n")
1717
self.assert_exact_text("xkcd: volume 0", "h3")

pytest.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@ markers =
2727
marker3: custom marker
2828
marker_test_suite: custom marker
2929
expected_failure: custom marker
30+
local: custom marker
31+
remote: custom marker
32+
offline: custom marker
33+
develop: custom marker
34+
qa: custom marker
35+
ready: custom marker
36+
master: custom marker
37+
release: custom marker
38+
staging: custom marker
39+
production: custom marker

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def main():
5454
data.append("[pytest]")
5555
data.append("addopts = --capture=no --ignore conftest.py "
5656
"-p no:cacheprovider")
57-
data.append("filterwarnings = ignore::pytest.PytestWarning")
57+
data.append("filterwarnings =")
58+
data.append(" ignore::pytest.PytestWarning")
59+
data.append(" ignore:.*U.*mode is deprecated:DeprecationWarning")
5860
data.append("junit_family = legacy")
5961
data.append("python_files = test_*.py *_test.py *_tests.py *_suite.py")
6062
data.append("python_classes = Test* *Test* *Test *Tests *Suite")
@@ -65,6 +67,16 @@ def main():
6567
data.append(" marker3: custom marker")
6668
data.append(" marker_test_suite: custom marker")
6769
data.append(" expected_failure: custom marker")
70+
data.append(" local: custom marker")
71+
data.append(" remote: custom marker")
72+
data.append(" offline: custom marker")
73+
data.append(" develop: custom marker")
74+
data.append(" qa: custom marker")
75+
data.append(" ready: custom marker")
76+
data.append(" master: custom marker")
77+
data.append(" release: custom marker")
78+
data.append(" staging: custom marker")
79+
data.append(" production: custom marker")
6880
data.append("")
6981
file_path = "%s/%s" % (dir_name, "pytest.ini")
7082
file = codecs.open(file_path, "w+", "utf-8")
@@ -99,7 +111,7 @@ def main():
99111
data.append(' self.click("link=About")')
100112
data.append(' self.assert_text("xkcd.com", "h2")')
101113
data.append(' self.open('
102-
'"https://store.xkcd.com/collections/everything")')
114+
'"://store.xkcd.com/collections/everything")')
103115
data.append(
104116
' self.update_text("input.search-input", "xkcd book\\n")')
105117
data.append(' self.assert_text("xkcd: volume 0", "h3")')
@@ -126,7 +138,7 @@ def main():
126138
data.append(" self.open('https://google.com/ncr')")
127139
data.append(" self.update_text('input[title=\"Search\"]', "
128140
"search_term + '\\n')")
129-
data.append(" self.assert_element('#resultStats')")
141+
data.append(" self.assert_element('#result-stats')")
130142
data.append(" self.assert_text(expected_text, '#search')")
131143
data.append("")
132144
file_path = "%s/%s" % (dir_name, "parameterized_test.py")

0 commit comments

Comments
 (0)