3 - Use selenium selenium Course notes in webdriver browser operation - positioning of page elements and operations

1, open the browser, open the page

. 1  from Selenium Import the webdriver
 2 DR = webdriver.Chrome ()
 . 3 dr.get ( ' http://www.baidu.com ' ) // open the page

2, is determined to open the browser is correct

dr.title
 // determine whether it is open Baidu
 ' Baidu '  in dr.title // get the page title, Baidu determine whether the word is contained in the title

 // method two 
b.get ( ' HTTP: //www.baidudu .com ' ) 
b.current_url 
' baidu '   in   b.current_url // get the current open url, it is determined whether the current baidu included in the url

3, selenium method of positioning elements

 

 Example:

 

 By positioning elements, navigate to the search box and type your search

. 1 dr.find_element_by_id ( ' kW ' ) // open the browser, Baidu found via search box id
 2 dr.send_keys ( ' python ' ) // type python in the search box
 . 3 dr.clear () // clear the input box content

 

Guess you like

Origin www.cnblogs.com/fyr2018/p/11511273.html