@@ -12,17 +12,17 @@ def test_find_by_classname():
12
12
13
13
def test_find_by_css_selector ():
14
14
driver = webdriver .Chrome ()
15
- driver .get ("https://www.selenium.dev/" )
15
+ driver .get ("https://www.selenium.dev/documentation/ " )
16
16
17
- driver .find_element (By .CSS_SELECTOR , "#announcement-banner " )
17
+ driver .find_element (By .CSS_SELECTOR , "#td-sidebar-menu " )
18
18
19
19
driver .quit ()
20
20
21
21
def test_find_by_id ():
22
22
driver = webdriver .Chrome ()
23
- driver .get ("https://www.selenium.dev/" )
23
+ driver .get ("https://www.selenium.dev/documentation/ " )
24
24
25
- driver .find_element (By .ID , "announcement-banner " )
25
+ driver .find_element (By .ID , "td-sidebar-menu " )
26
26
27
27
driver .quit ()
28
28
@@ -66,19 +66,57 @@ def test_find_by_xpath():
66
66
67
67
driver .quit ()
68
68
69
- def find_by_relative_locators ():
69
+ def test_relative_locators_above ():
70
70
driver = webdriver .Chrome ()
71
- driver .get ("https://www.selenium.dev/" )
71
+ driver .get ("https://www.selenium.dev/selenium/web/inputs.html" )
72
+
73
+ email_input = driver .find_element (locate_with (By .TAG_NAME , "input" ).above ({ By .NAME : "password_input" }))
74
+ email_input .
send_keys (
"[email protected] " )
75
+
76
+ driver .quit ()
77
+
78
+ def test_relative_locators_below ():
79
+ driver = webdriver .Chrome ()
80
+ driver .get ("https://www.selenium.dev/selenium/web/inputs.html" )
81
+
82
+ password_input = driver .find_element (locate_with (By .TAG_NAME , "input" ).below ({ By .NAME : "email_input" }))
83
+ password_input .send_keys ("randompassword" )
84
+
85
+ driver .quit ()
72
86
73
- email_locator = locate_with (By .TAG_NAME , "input" ).above ({By .ID : "password" })
87
+ def test_relative_locators_to_the_left_of ():
88
+ driver = webdriver .Chrome ()
89
+ driver .get ("https://www.selenium.dev/selenium/web/inputs.html" )
90
+
91
+ button = driver .find_element (locate_with (By .TAG_NAME , "input" ).to_left_of ({ By .NAME : "submit_input" }))
92
+ button .click ()
74
93
75
- password_locator = locate_with ( By . TAG_NAME , "input" ). below ({ By . ID : "email" } )
94
+ driver . quit ( )
76
95
77
- cancel_locator = locate_with (By .TAG_NAME , "button" ).to_left_of ({By .ID : "submit" })
96
+ def test_relative_locators_to_the_right_of ():
97
+ driver = webdriver .Chrome ()
98
+ driver .get ("https://www.selenium.dev/selenium/web/inputs.html" )
78
99
79
- submit_locator = locate_with (By .TAG_NAME , "button" ).to_right_of ({By .ID : "cancel" })
100
+ button = driver .find_element (locate_with (By .TAG_NAME , "input" ).to_right_of ({ By .NAME : "reset_input" }))
101
+ button .click ()
80
102
81
- email_locator = locate_with (By .TAG_NAME , "input" ).near ({By .ID : "lbl-email" })
103
+ driver .quit ()
104
+
105
+ def test_relative_locators_near ():
106
+ driver = webdriver .Chrome ()
107
+ driver .get ("https://www.selenium.dev/selenium/web/inputs.html" )
82
108
83
- submit_locator = locate_with (By .TAG_NAME , "button" ).below ({By .ID : "email" }).to_right_of ({By .ID : "cancel" })
109
+ button = driver .find_element (locate_with (By .TAG_NAME , "input" ).near ({ By .NAME : "week_input" }))
110
+ button .send_keys ('someweek' )
111
+
112
+ driver .quit ()
113
+
114
+ def test_relative_locators_below_and_right_of ():
115
+ driver = webdriver .Chrome ()
116
+ driver .get ("https://www.selenium.dev/selenium/web/inputs.html" )
117
+
118
+ button = driver .find_element (locate_with (By .TAG_NAME , "input" ).below ({ By .NAME : "week_input" }).to_right_of ({ By .NAME : "button_input" }))
119
+ button .click ()
120
+
121
+ driver .quit ()
84
122
0 commit comments