@@ -29,8 +29,11 @@ methods to locate elements in a page:
2929
3030
3131Apart from the public methods given above, there are two private
32- methods which might be useful with locators in page objects. These
33- are the two private methods: `find_element ` and `find_elements `.
32+ methods which might be useful for locating page elements:
33+
34+ - `find_element `
35+ - `find_elements `
36+
3437
3538Example usage::
3639
@@ -55,10 +58,10 @@ These are the attributes available for `By` class::
5558Locating by Id
5659~~~~~~~~~~~~~~
5760
58- Use this when you know `id ` attribute of an element. With this
59- strategy, the first element with the `id ` attribute value matching the
60- location will be returned. If no element has a matching `id `
61- attribute, a ``NoSuchElementException `` will be raised.
61+ Use this when you know the `id ` attribute of an element. With this
62+ strategy, the first element with a matching `id ` attribute will
63+ be returned. If no element has a matching `id ` attribute,
64+ a ``NoSuchElementException `` will be raised.
6265
6366For instance, consider this page source::
6467
@@ -80,10 +83,10 @@ The form element can be located like this::
8083Locating by Name
8184~~~~~~~~~~~~~~~~
8285
83- Use this when you know `name ` attribute of an element. With this
84- strategy, the first element with the `name ` attribute value matching
85- the location will be returned. If no element has a matching `name `
86- attribute, a ``NoSuchElementException `` will be raised.
86+ Use this when you know the `name ` attribute of an element. With this
87+ strategy, the first element with a matching `name ` attribute will
88+ be returned. If no element has a matching `name ` attribute,
89+ a ``NoSuchElementException `` will be raised.
8790
8891For instance, consider this page source::
8992
@@ -115,8 +118,8 @@ Locating by XPath
115118XPath is the language used for locating nodes in an XML document. As
116119HTML can be an implementation of XML (XHTML), Selenium users can
117120leverage this powerful language to target elements in their web
118- applications. XPath extends beyond (as well as supporting) the simple
119- methods of locating by id or name attributes, and opens up all sorts
121+ applications. XPath supports the simple methods of locating by
122+ id or name attributes and extends them by opening up all sorts
120123of new possibilities such as locating the third checkbox on the page.
121124
122125One of the main reasons for using XPath is when you don't have a
@@ -157,34 +160,30 @@ The form elements can be located like this::
157160
1581612. First form element in the HTML
159162
160- 3. The form element with attribute named `id ` and the value `loginForm `
163+ 3. The form element with attribute `id ` set to `loginForm `
161164
162165The username element can be located like this::
163166
164167 username = driver.find_element_by_xpath("//form[input/@name='username']")
165168 username = driver.find_element_by_xpath("//form[@id='loginForm']/input[1]")
166169 username = driver.find_element_by_xpath("//input[@name='username']")
167170
168- 1. First form element with an input child element with attribute named
169- `name ` and the value `username `
171+ 1. First form element with an input child element with `name ` set to `username `
170172
171- 2. First input child element of the form element with attribute named
172- `id ` and the value `loginForm `
173+ 2. First input child element of the form element with attribute `id ` set to `loginForm `
173174
174- 3. First input element with attribute named 'name' and the value
175- `username `
175+ 3. First input element with attribute `name ` set to `username `
176176
177177The "Clear" button element can be located like this::
178178
179179 clear_button = driver.find_element_by_xpath("//input[@name='continue'][@type='button']")
180180 clear_button = driver.find_element_by_xpath("//form[@id='loginForm']/input[4]")
181181
182182
183- 1. Input with attribute named `name ` and the value `continue ` and
184- attribute named `type ` and the value `button `
183+ 1. Input with attribute `name ` set to `continue ` and
184+ attribute `type ` set to `button `
185185
186- 2. Fourth input child element of the form element with attribute named
187- `id ` and value `loginForm `
186+ 2. Fourth input child element of the form element with attribute `id ` set to `loginForm `
188187
189188These examples cover some basics, but in order to learn more, the
190189following references are recommended:
@@ -212,9 +211,9 @@ discovering the XPath of an element:
212211Locating Hyperlinks by Link Text
213212~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214213
215- Use this when you know link text used within an anchor tag. With this
216- strategy, the first element with the link text value matching the
217- location will be returned. If no element has a matching link text
214+ Use this when you know the link text used within an anchor tag. With this
215+ strategy, the first element with the link text matching the provided value
216+ will be returned. If no element has a matching link text
218217attribute, a ``NoSuchElementException `` will be raised.
219218
220219For instance, consider this page source::
@@ -258,9 +257,9 @@ The heading (h1) element can be located like this::
258257Locating Elements by Class Name
259258~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
260259
261- Use this when you want to locate an element by class attribute name.
262- With this strategy, the first element with the matching class attribute
263- name will be returned. If no element has a matching class attribute name,
260+ Use this when you want to locate an element by class name.
261+ With this strategy, the first element with the matching class name
262+ attribute will be returned. If no element has a matching class name attribute ,
264263a ``NoSuchElementException `` will be raised.
265264
266265For instance, consider this page source::
@@ -278,9 +277,9 @@ The "p" element can be located like this::
278277Locating Elements by CSS Selectors
279278~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
280279
281- Use this when you want to locate an element by CSS selector syntax.
282- With this strategy, the first element with the matching CSS selector
283- will be returned. If no element has a matching CSS selector,
280+ Use this when you want to locate an element using CSS selector syntax.
281+ With this strategy, the first element matching the given CSS selector
282+ will be returned. If no element matches the provided CSS selector,
284283a ``NoSuchElementException `` will be raised.
285284
286285For instance, consider this page source::
0 commit comments