From selenium import webdriver
#webElement接口常用方法
#clear (): Clears the contents of the text box
#send_ Keys (): Analog keyboard input
#click (): Click the button, can be clicked on the element;
#可以是任何可以点击的文字, Picture link, radio box, check box, Drop-down box
#submit (): Submit the form, especially if there is no submit button
#size: Get element size
#text: Get element text
#get_attribute (name): Get property value
driver=webdriver. Ie ()
driver.get ("https://www.baidu.com")
#百度输入框中输入test
driver.find_element_by_id (' kw '). Send_ The Keys ("test") Sleep
(4)
#清除test
driver.find_element_by_id (' kw '). Clear () Sleep
(4)
driver.find_element_by_id (' kw '). Send_keys ("python")
#submit相当于回车
driver.find_element_by_id (' kw '). Submit () Sleep
(4)
#获取百度搜索框id的属性值
attribute=driver.find_element_by_id ("kw"). Get_attribute ("id")
print ("Attibute:", attribute)
#获取百度输入框的尺寸
size=driver.find_element_by_id ("kw"). Size
Print ( "Size:", size)
#获取百度首页百度按钮的文本信息
text=driver.find_element_by_id ("su"). Text
print ("The textual message of the Baidu button is:", Text) sleep
(5)
driver.quit ()