Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit d2634e5

Browse files
committed
docs(locators): readability improvements
1 parent 34ab492 commit d2634e5

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

Diff for: docs/locators.md

+25-23
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Using Locators
22
==============
33

4-
The heart of end to end tests for webpages is finding DOM elements, interacting with them, and getting information about the current state of your application. This doc is an overview of how to locate and perform actions on DOM elements using Protractor.
4+
The heart of end-to-end tests for webpages is finding DOM elements, interacting with them, and getting information about the current state of your application. This doc is an overview of how to locate and perform actions on DOM elements using Protractor.
55

66
Overview
77
--------
@@ -31,7 +31,7 @@ by.model('name')
3131
by.binding('bindingname')
3232
```
3333

34-
See a [list of Protractor specific locators](/docs/api.md#api-protractorby).
34+
For a list of Protractor-specific locators, see the [Protractor API: ProtractorBy](/docs/api.md#api-protractorby).
3535

3636
The locators are passed to the `element` function, as below:
3737

@@ -54,7 +54,7 @@ element(by.css('my-css'));
5454
Actions
5555
-------
5656

57-
`element()` returns an ElementFinder object. The ElementFinder knows how to locate the DOM element using the locator you passed in as a parameter, but it has not actually done so yet. It will not contact the browser until an *action* method has been called.
57+
The `element()` function returns an ElementFinder object. The ElementFinder knows how to locate the DOM element using the locator you passed in as a parameter, but it has not actually done so yet. It will not contact the browser until an *action* method has been called.
5858

5959
The most common action methods are:
6060

@@ -114,28 +114,30 @@ element.all(locator).last();
114114
Finding Sub-Elements
115115
--------------------
116116

117-
Simply chain element and element.all together to find sub-elements. For example:
117+
To find sub-elements, simply chain element and element.all functions together. For example,
118+
Using a single locator to find:
118119

119-
Using a single locator to find an element:
120+
- an element
121+
```js
122+
element(by.css('some-css'));
123+
```
120124

121-
```js
122-
element(by.css('some-css'));
123-
```
125+
- a list of elements:
126+
```js
127+
element.all(by.css('some-css'));
128+
```
124129

125-
Using a single locator to find a list of elements:
126-
```js
127-
element.all(by.css('some-css'));
128-
```
130+
Using chained locators to find:
129131

130-
to find a sub-element:
131-
```js
132-
element(by.css('some-css')).element(by.tag('tag-within-css'));
133-
```
132+
- a sub-element:
133+
```js
134+
element(by.css('some-css')).element(by.tag('tag-within-css'));
135+
```
134136

135-
to find a list of sub-elements:
136-
```js
137-
element(by.css('some-css')).all(by.tag('tag-within-css'));
138-
```
137+
- to find a list of sub-elements:
138+
```js
139+
element(by.css('some-css')).all(by.tag('tag-within-css'));
140+
```
139141

140142
You can chain with get/first/last as well like so:
141143

@@ -145,7 +147,7 @@ element.all(by.css('some-css')).get(index).element(by.tag('tag-within-css'));
145147
element.all(by.css('some-css')).first().all(by.tag('tag-within-css'));
146148
```
147149

148-
Behind the scenes: ElementFinders versus WebElements
150+
Behind the Scenes: ElementFinders versus WebElements
149151
----------------------------------------------------
150152

151153
If you're familiar with WebDriver and WebElements, or you're just curious about the WebElements mentioned above, you may be wondering how they relate to ElementFinders.
@@ -163,7 +165,7 @@ var myButton = element(locator);
163165
// No command has been sent to the browser yet.
164166
```
165167
166-
Not until you call an action will the browser recieve any commands.
168+
The browser will not receive any commands until you call an action.
167169
168170
```js
169171
myButton.click();
@@ -174,5 +176,5 @@ ElementFinders also enable chaining to find subelements, such as `element(locato
174176
175177
All WebElement actions are wrapped in this way and available on the ElementFinder, in addition to a couple helper methods like `isPresent`.
176178
177-
You may always access the underlying WebElement using `element(locator).getWebElement()`, but you should not need to.
179+
You can always access the underlying WebElement using `element(locator).getWebElement()`, but you should not need to.
178180

0 commit comments

Comments
 (0)