Common interface Methods
Submit #提交表单, especially if there is no submit button, for example, enter in the search box and return to Operation
# Coding=utf-8 from
Selenium import webdriver
import time
driver = Webdriver. Firefox ()
driver.get (' http://www.youdao.com ')
driver.find_element_by_id (' translatecontent '). Send_keys ( ' Hello ')
driver.find_element_by_id (' translatecontent '). Submit () #点击回车键
Print (driver.title)
Time.sleep (2)
driver.quit ()
Note: SUBM () and click () can be exchanged, submit () can also be clicked button
Size: return element dimensions
Text: returning element text
Get_attribute (name): Get property value
Is_dispalyed (): Whether the element is visible to the user
# Coding=utf-8 from
Selenium import webdriver
import time
driver = Webdriver. Firefox ()
driver.get (' http://www.baidu.com ')
#获得输入框尺寸
size = driver.find_element_by_id (' kw '). Size
print (size)
#返回百度页面底部备案 result
= Driver.find_element_by_class_name (' Ftcon-wrapper '). Text
Print (Result)
#返回元素是否可见
result1 = driver.find_element_by_id (' kw '). is_displayed ()
print (RESULT1)
Driver.quit ()