File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -16,15 +16,21 @@ def test_with_frames(self):
1616 driver .switch_to .frame ('frame-middle' )
1717 self .assertTrue (driver .find_element_by_id ('content' ).text == "MIDDLE" , "content should be MIDDLE" )
1818
19- # https://github.com/tourdedave/elemental-selenium-tips/blob/master/04-work-with-multiple-windows /python/windows .py
20- def test_with_windows (self ):
19+ # https://github.com/tourdedave/elemental-selenium-tips/blob/master/05-select-from-a-dropdown /python/dropdown .py
20+ def test_select_from_a_dropdown (self ):
2121 driver = self .driver
22- driver .get ('http://the-internet.herokuapp.com/windows' )
23- driver .find_element_by_css_selector ('.example a' ).click ()
24- driver .switch_to_window (driver .window_handles [0 ])
25- self .assertTrue (driver .title != "New Window" , "title should not be New Window" )
26- driver .switch_to_window (driver .window_handles [- 1 ])
27- self .assertTrue (driver .title == "New Window" , "title should be New Window" )
22+ driver .get ('http://the-internet.herokuapp.com/dropdown' )
23+ dropdown_list = driver .find_element_by_id ('dropdown' )
24+ options = dropdown_list .find_elements_by_tag_name ('option' )
25+ for opt in options :
26+ if opt .text == 'Option 1' :
27+ opt .click ()
28+ break
29+ for opt in options :
30+ if opt .is_selected ():
31+ selected_option = opt .text
32+ break
33+ self .assertTrue (selected_option == 'Option 1' , "Selected option should be Option 1" )
2834
2935 # https://github.com/tourdedave/elemental-selenium-tips/blob/master/13-work-with-basic-auth/python/basic_auth_1.py
3036 def test_visit_basic_auth_secured_page (self ):
You can’t perform that action at this time.
0 commit comments