selenium-- drop-down box processing

# ################################################# ### 
# # drop-down menu processing 
# ######################################### ########### 

from selenium.webdriver.support.ui Import the Select 

B = webdriver.Chrome () 
b.implicitly_wait ( 10 ) 
b.get ( ' File: /// E: / ZM20190316 / 2 .Selenium / TestDemo / SelectListDemo.html ' ) 
b.maximize_window () 

slt_ele = b.find_element_by_id ( " ShippingMethod " )
 # using the index to select an index entry 
# the select (slt_ele) .select_by_index (2) 
#Using the value attribute value selection entry 
# the Select (slt_ele) .select_by_value ( "11.61") 
# use text entry value selecting 
the Select (slt_ele) .select_by_visible_text ( " the UPS Ground ==> $ 8.34 " ) 

SLEEP ( . 3 ) 
b.quit ()

 

Guess you like

Origin www.cnblogs.com/chen-huan/p/11011307.html