Selenium other automated operations

from Selenium Import the webdriver
 from Time Import SLEEP 

Bro = webdriver.Firefox () 
bro.get ( ' https://www.taobao.com/ ' )
 # page_text bro.page_source = () 

# implemented label location 
search_input = bro.find_element_by_id ( ' Q ' )
 # tag interaction 
search_input.send_keys ( ' Iphone ' ) 

# perform a set js code (scrolling a screen height) 
bro.execute_script ( ' the window.scrollTo (0, document.body.scrollHeight) ' )
 #Click the Search button 
btn = bro.find_element_by_css_selector ( ' .btn-Search ' ) 
btn.click () 

bro.get ( ' https://wwww.baidu.com ' ) 
SLEEP ( 2 )
 # fallback 
bro.back ()
 # Forward 
bro.forward () 

sleep ( 5 ) 
bro.quit ()

 

Guess you like

Origin www.cnblogs.com/huahuawang/p/12692931.html