Skip to content

Commit 30e93d8

Browse files
committed
Add a test
1 parent 8d373c1 commit 30e93d8

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

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")

0 commit comments

Comments
 (0)