Methods of the Webelement class, commonly summarized as follows:
Clear () Clears the contents of the input box, such as when logging in
driver.find_element_by_id (' username '). Clear ()
Click (), for example click the login button
driver.find_element_by_id (' Submit '). Click ()
Get_attribute () Gets the value of the element property
zhi=driver.find_element_by_id (' su '). Get_attribute (' type ') to get Baidu home page, "Baidu a bit" the value of the property type, run the result is "submit"
The is_enabled () element is editable and the return value is Boolean
Driver.get (' https://www.baidu.com/')
zhi=driver.find_element_by_id (' su ')
Print zhi.is_enabled ()
Run result is true
Is_displayed () element is visible, returns a Boolean
Is_selected () element is selected, returns a Boolean
Test Baidu--settings--Check whether the radio button on the Settings page is selected
The code is as follows
#coding =utf-8
From Selenium import Webdriver
From selenium.webdriver.common.action_chains import actionchains
Import Time
Driver=webdriver. Firefox ()
Driver.maximize_window ()
driver.implicitly_wait (+)
driver.get (' https://www.baidu.com/')
shezhi=driver.find_element_by_link_text (U ' set ')
actionchains (Driver). Move_to_element (Shezhi). Perform ()
driver.find_element_by_css_selector ('. Setpref '). Click ()
print driver.find_element_by_id (' s1_2 '). is_selected ()
driver.quit ()
"Do not show" in the location, run result: False
send_keys () input content
element.send_keys (U "Xian")
submit () generally used for submission from form
Methods of the Webelement class