Chapter 4 WebDriver API - Selenium3 automated testing

Chapter 4 WebDriver API

From the beginning of this chapter formal learning API WebDriver , it can be used to operate some of the classes and methods browser elements .

4.1 Starting position elements

Baidu's home page, for example, input boxes, buttons, text links, images and other elements on the page. Automated testing to do is simulate a mouse and keyboard to operate these elements, such as click, enter, and so on mouseover.
The premise of the operation of these elements is to locate them. Automation tools, how to locate these elements?
You can see through the browser that comes with (F12) Developer Tools, page elements are composed of HTML code, there are hierarchically organized between them, each element has a different tag names and attribute values. WebDriver is based on this information to locate elements.

Provides eight elements WebDriver positioning method in Python, corresponding to the following methods:

● id 定位 → find_element_by_id()
● name 定位 → find_element_by_name()
● tag 定位 → find_element_by_tag_name()
● class 定位 → find_element_by_class_name()
● link_text → find_element_by_link_text()
● partial link 定位 → find_element_by_partial_link_text()
● XPath 定位 → find_element_by_xpath()
● CSS_selector 定位 → find_element_by_css_selector()

 

Guess you like

Origin www.cnblogs.com/MarlonKang/p/12417229.html