[Python reptile] selenuim common method summary

 

1, access to the current page Url

  Methods: current_url

  Examples: Driver . Current_url

2, to obtain the coordinates of the elements

  Methods: location

  Explanation: First, find the element you want to get, and then call location method

  实例:driver.find_element_by_xpath("xpath").location

3, form submission

  Methods: submit

  Explanation : find the form ( from ) can be called directly submit

  实例:driver.find_element_by_id("form1").submit()

4, get the CSS property values

  Methods: value_of_css_property ( css_name )

  实例:driver.find_element_by_css_selector("input.btn").value_of_css_property("input.btn")

5, the property value acquisition element

  方法:get_attribute(element_name)

  实例:driver.find_element_by_id("kw").get_attribute("kw")

6, to determine whether the element is selected

  Methods: is_selected ( )

  实例:driver.find_element_by_id("form1").is_selected()

7, returns the element size

  Methods: size

  实例:driver.find_element_by_id("iptPassword").size

  Return Value: { 'width' : 250 , 'height' : 30 }

8, it is judged whether the element

  Methods: is_displayed ( )

  实例:driver.find_element_by_id("iptPassword").is_displayed()

9, it is judged whether the element to be used

  Methods: is_enabled ( )

  实例:driver.find_element_by_id("iptPassword").is_enabled()

10, to obtain elements of a text value

  Methods: text

  实例:driver.find_element_by_id("iptUsername").text

11, elements assignment

  方法:send_keys(*values)

  实例:driver.find_element_by_id("iptUsername").send_keys('admin')

12, returns the element's tagName

  Methods: tag_name

  实例:driver.find_element_by_id("iptUsername").tag_name

13, delete all browser cookies

  Methods: delete_all_cookies ( )

  Examples: Driver . Delete_all_cookies ( )

14, delete the specified cookie

  METHOD: Delete_cookie ( Name )

  实例:deriver.delete_cookie("my_cookie_name")

15, close the browser

  Method: use Close ( )

  Examples: Driver . Use Close ( )

16, close the browser and exit the driver

  Methods: quit ( )

  Examples: Driver . Quit ( )

17 Back

  Methods: the Back ( )

  Examples: Driver . The Back ( )

18, input box empty

  Methods: the Clear ( )

  Examples: Driver . The Clear ( )

19, maximize the browser window

  Methods: maximize_window ( )

  Examples: Driver . Maximize_window ( )

20, see the browser name

  Methods: name

  Examples: drvier . Name

21, returned in the current session cookies

  Methods: get_cookies ( )

  Examples: Driver . Get_cookies ( )

22, find the map based on the value of cookie name Value

  方法:driver.get_cookie(cookie_name)

  实例:driver.get_cookie("NET_SessionId")

23, interception of the current page

  方法:save_screenshot(filename)

  实例:driver.save_screenshot("D:\\Program Files\\Python27\\NM.bmp")

Guess you like

Origin www.cnblogs.com/Tree0108/p/12080971.html