1, get the length and width of the current window Method: get_window_size() Example: driver.get_window_size()
2、Get the version number of the browser method: capablities['version'] Example: drvier.capablities['version'] # print the value of the browser's version
3、Get the attribute value of the element Method: get_attribute(element_name) Example: driver.find_element_by_id("kw").get_attribute("type")
4, get the value of CSS properties method: value_of_css_property(css_name) Example: driver.find_element_by_id("su").value_of_css_property("color")
5、Submission of the form method: submit Explanation: find the form (from) directly call submit can be Example: driver.find_element_by_id("su").submit()
6、Return to the previous page Method: back() Example: driver.back()
7, through the label of the class attribute to find elements method: find_elements_by_class_name (class_name) Example: driver.find_elements_by_class_name("s_ipt")
8, browser window maximization Method: maximize_window() Example: driver.maximize_window()
9, determine whether the element is used Method: is_enabled() Example: driver.find_element_by_id("kw").is_enabled()
10, set the wait timeout Method: implicitly_wait(wait_time) Example: driver.implicitly_wait(
11, through the tag name tagname find element method: find_element_by_tag_name (tag_name) Example: driver.find_element_by_tag_name("input") Note: Find by tag_name uses find_element_by_tag_name to find the tag_name of the first tag.
12, get the coordinates of the current window Method: get_window_position() Example: driver.get_window_position()
13、Get a new TAB in the browser method: trigger ctrl + c Example: drvier.find_element_by_tag_name('body').send_keys(Keys.CONTROL+'t') # trigger Ctrl+c
14, get the current page Url function Method: current_url Example: driver.current_url
15. Input values Method: send_keys(*values) Example: driver.find_element_by_id("kw").send_keys('admin') Note that if it is Chinese you need to add udriver.find_element_by_id("kw").send_keys(u'youth')
16, intercept the current page method: get_screenshot_as_file(filename) Example: driver.get_screenshot_as_file(r "C:\Users\Eric\Desktop\test.png")
17, through the css style to find elements method: find_element_by_css_selector() Example: driver.find_element_by_css_selector("#kw")
18, return to the element's tagName Method: tag_name Example: driver.find_element_by_id("kw").tag_name
19, get element coordinates Method: location Explanation: First find the element you want to get, and then call the location method Example: driver.find_element_by_id("kw").location
20, delete the browser so cookies Method: delete_all_cookies() Example: driver.delete_all_cookies()
21, to determine whether the element is selected Method: is_selected() Example: driver.find_element_by_id("form1").is_selected()
22, get the text value of the element Method: text Example: driver.find_element_by_class_name("mnav").text
23、Refresh the current browser Method: refresh Example: drvier.refresh()
24、Return the size of the element Method: size Example: driver.find_element_by_id("kw").size Return Value: {'width':'height':38}
25, through the label attribute Id find elements method: find_element_by_id(element_id) Example: driver.find_element_by_id("kw")
26, through the label in the element text link to find elements method: find_element_by_link_text (link_text) Example: driver.find_element_by_link_text('Baidu')
27. Load url in browser method: get(url) Example: driver.get("http://www.baidu.com")
28, through the label Xpath path to find elements method: find_element_by_xpath(xpath) Example: driver.find_element_by_xpath("//*[@]")
29. Close the browser Method: close() Example: driver.close()
30, return to the current session cookies Method: get_cookies() Example: driver.get_cookies()
31、Check the name of the browser Method: name Example: drvier.name
32. forward Method: forward() Example: driver.forward()
33. Close the browser and launch the driver Method: quit() Example: driver.quit()
34, determine whether the element is displayed Method: is_displayed() Example: driver.find_element_by_id("kw").is_displayed()
35, according to the cookie name to find Method: driver.get_cookie(cookie_name) Example: driver.get_cookie("NET_SessionId")
36, through the label attribute name to find elements method: find_element_by_name(element_name) Example: driver.find_element_by_name("wd")
37. Delete the specified cookie Method: delete_cookie(name) Example: deriver.delete_cookie("my_cookie_name")