Common methods in Webdriver:
Clear () Erase text
Send_keys (*value) analog key input
Click () stand-alone element
Landing of the website
From selenium import webdriverfrom time import *driver = webdriver. Chrome () url = "https://login.huawei.com/login/?redirect=http%3A%2F%2Fw3.huawei.com%2Fnext% 2findexa.html "Print (' new access %s ' % (URL)) driver.get (URL) driver.find_element_by_id (' uid '). Clear () driver.find_element_by_id (' uid '). Send_keys ("c00358145") Sleep (3) driver.find_element_by_id (' Password '). Clear () driver.find_element_by_id (' Password '). Send_keys ("&ctt1106648034") Driver.find_element_by_class_name ( ' BTN '). Click () Sleep (3) driver.quit () 2.WebElement interface Common methods The Submit () method is used to submit the form from selenium import Webdriverfrom time import *driver = webdriver. Chrome () url = "https://www.baidu.com" Print (' new access %s ' % (URL)) driver.get (URL) driver.find_element_by_id (' kw '). Clear () driver.find_element_by_id (' kw '). Send_keys ("c00358145") Sleep (3) driver.find_element_by_id (' kw '). Submit () Sleep (3) driver.quit ()
Locate the search box by submitting the content of the search box to reach the Click search button effect, and sometimes can be used with the click () function Exchange
Method: Size () returns the dimension of the element
Text () Gets the literal of the element
Get_attribute (name) Gets the value of the property
Is_displayed () Set the element down payment user visible
From selenium import Webdriver
From time Import *
Driver = Webdriver. Chrome ()
url = "Https://www.baidu.com"
Print (' New access%s '% (URL))
Driver.get (URL)
Size = driver.find_element_by_id (' kw '). Size
Print (' size%s '%size)
Text = Driver.find_element_by_xpath ("//*[@id = ' U1 ']/a[1]"). Text
Print (' text%s '%text)
attribute = driver.find_element_by_id (' kw '). Get_attribute (' type ')
Print ('%s '%attribute)
Sleep (3)
Driver.quit ()
Selenium Learning: simple element manipulation