Import the webdriver Selenium from Driver = webdriver.Chrome () driver.get ( "https://www.baidu.com/") #WebDriver some methods commonly used in the "" " (. 1) Clear () clear text Example: Driver. find_element_by_id ( "kw") send_keys ( " learning test"). driver.find_element_by_id ( "kW") Clear (). (2) send_keys (value) Example analog input: . driver.find_element_by_id ( "kW") send_keys ( "test learning ") (3) the click () click element Example: driver.find_element_by_id (". ") send_keys (" kw test learning ") . driver.find_element_by_id (" kw ") the click () (4) the submit () to submit the form when when there is no search button Example: driver.find_element_by_id ( "kw") send_keys ( "test learning"). driver.submit () "" "
# Get the size of the input block size = driver.find_element_by_id ( "kW"). Size Print (size)
# Get the record text information text = driver.find_element_by_id ( "cp") text. Print (text) # Gets the element attributes: id, name, class and so on . Attribute = driver.find_element_by_id ( "kw" ) get_attribute ( "name") Print (attribute) # returned element is visible, visible return True, invisible return False the Result = driver.find_element_by_id ( "kw"). is_displayed () Print (the Result) driver.quit ()