Driver = Webdriver. Chrome (Chromedriver)
1. Return cookies:driver.get_cookies () in the current session
2, according to the cookie name search: Driver.get_cookie (cookiename)
3, intercept the current page :get_screenshot_as_file (filename), such as: Get_screenshot_as_file ("D:\\nm.bmp")
4. Get the coordinates of the current window :driver.get_window_position ()
5. Get the length and width of the current window :driver.get_window_size ()
6. Get the URL of the current page:driver.current_url
7. Get the coordinates of the element: get to the element first, then call the Location property
Driver.find_element_by_xpath ("//*[@id = ' Tablechart ']/tbody/tr[14]/td[9]"). location
8. Get CSS Property values:value_of_css_property (css_name)
driver.find_element_by_css_selector ("input.btn"). Value_of_css_property ("input.btn")
9. gets the attribute value of the element: Get_attribute (element_name)
driver.find_element_by_id ("Sellaiyuan"). Get_attribute ("Sellaiyuan")
10. Determine if the element is selected : is_selected ()
driver.find_element_by_id ("Form1"). Is_selected ()
11, return the size of the element : Size
driver.find_element_by_id ("Iptpassword"). Size
size return value: {' width ': +, ' height ':
12. Determine if the element is displayed : is_displayed ()
driver.find_element_by_id ("Iptpassword"). Is_displayed ()
13. Determine if the element is being used method: is_enabled ()
driver.find_element_by_id ("Iptpassword"). Is_enabled ()
14. Gets the text value of the element Method: Text
driver.find_element_by_id ("Iptusername"). Text
15. Assigning Values to elements Method: Send_keys (*values)
driver.find_element_by_id ("Iptusername"). Send_keys (' admin ')
PS: Note If it is Chinese need to increase the escape character U, eg. driver.find_element_by_id ("Iptusername"). Send_keys (U ' Youth ')
16. Return the tag name of the element: tag_name
driver.find_element_by_id ("Iptusername"). tag_name
17. Delete all cookies from the browser :delete_all_cookies ()
Driver.delete_all_cookies ()
18. Delete the specified cookie : Delete_cookie (name)
Driver.delete_cookie ("My_cookie_name")
19. Close the browser method: Close ()
Driver.close ()
20. Close the browser and exit the driver : Quit ()
Driver.quit ()
21. Back to Previous page : Back ()
Driver.back ()
22, set the Wait timeout method : implicitly_wait (wait_time)
Driver.implicitly_wait (30)
23. Maximize the browser window : Maximize_window ()
Driver.maximize_window ()
24. Check the name of the browser : Name
Drvier.name
Common functions of Python in selenium2