Skip to content

Commit

Permalink
docs: add missing async in grab* functions docs (codeceptjs#2320)
Browse files Browse the repository at this point in the history
* docs: add missing async in grab* functions docs

* docs: add returned value in docs for grabGeoLocation
  • Loading branch information
elukoyanov authored May 5, 2020
1 parent fb7fc57 commit de8a82b
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 23 deletions.
9 changes: 7 additions & 2 deletions docs/helpers/Appium.md
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ Returns **[Promise][13]<[string][4]>** HTML code for an element

Retrieves an attribute from an element located by CSS or XPath and returns it to test.
An array as a result will be returned if there are more than one matched element.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let hint = await I.grabAttributeFrom('#tooltip', 'title');
Expand Down Expand Up @@ -1419,7 +1419,7 @@ I.seeInSource('<h1>Green eggs &amp; ham</h1>');
### grabSource

Retrieves page source and returns it to test.
Resumes test execution, so should be used inside an async function.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let pageSource = await I.grabSource();
Expand Down Expand Up @@ -1495,6 +1495,7 @@ I.seeAttributesOnElements('//form', { method: "post"});
### grabNumberOfVisibleElements

Grab number of visible elements by locator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let numOfElements = await I.grabNumberOfVisibleElements('p');
Expand Down Expand Up @@ -1663,6 +1664,7 @@ I.switchTo(); // switch back to main page
### grabNumberOfOpenTabs

Grab number of open tabs.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let tabs = await I.grabNumberOfOpenTabs();
Expand Down Expand Up @@ -1715,11 +1717,14 @@ I.setGeoLocation(121.21, 11.56, 10);
### grabGeoLocation

Return the current geo location
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let geoLocation = await I.grabGeoLocation();
```

Returns **[Promise][13]&lt;{latitude: [number][8], longitude: [number][8], altitude: [number][8]}>**

### grabElementBoundingRect

Grab the width, height, location of given locator.
Expand Down
5 changes: 3 additions & 2 deletions docs/helpers/Nightmare.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
An array as a result will be returned if there are more than one matched element.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let hint = await I.grabAttributeFrom('#tooltip', 'title');
Expand All @@ -438,7 +438,7 @@ Returns **[Promise][8]&lt;[string][3]>** attribute value
Gets a cookie object by name.
If none provided gets all cookies.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let cookie = await I.grabCookie('auth');
Expand Down Expand Up @@ -492,6 +492,7 @@ Returns **[Promise][8]&lt;[string][3]>** HTML code for an element
### grabNumberOfVisibleElements
Grab number of visible elements by locator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let numOfElements = await I.grabNumberOfVisibleElements('p');
Expand Down
8 changes: 5 additions & 3 deletions docs/helpers/Playwright.md
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ I.forceClick('Click me', '#hidden');

Retrieves an attribute from an element located by CSS or XPath and returns it to test.
An array as a result will be returned if there are more than one matched element.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let hint = await I.grabAttributeFrom('#tooltip', 'title');
Expand Down Expand Up @@ -682,7 +682,7 @@ Returns **[Promise][9]&lt;[Array][10]&lt;any>>**

Gets a cookie object by name.
If none provided gets all cookies.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let cookie = await I.grabCookie('auth');
Expand Down Expand Up @@ -794,6 +794,7 @@ Returns **[Promise][9]&lt;[string][7]>** HTML code for an element
### grabNumberOfOpenTabs

Grab number of open tabs.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let tabs = await I.grabNumberOfOpenTabs();
Expand All @@ -804,6 +805,7 @@ Returns **[Promise][9]&lt;[number][8]>** number of open tabs
### grabNumberOfVisibleElements

Grab number of visible elements by locator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let numOfElements = await I.grabNumberOfVisibleElements('p');
Expand Down Expand Up @@ -839,7 +841,7 @@ Returns **[Promise][9]&lt;([string][7] | null)>**
### grabSource

Retrieves page source and returns it to test.
Resumes test execution, so should be used inside an async function.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let pageSource = await I.grabSource();
Expand Down
8 changes: 5 additions & 3 deletions docs/helpers/Protractor.md
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
An array as a result will be returned if there are more than one matched element.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let hint = await I.grabAttributeFrom('#tooltip', 'title');
Expand Down Expand Up @@ -598,7 +598,7 @@ Returns **[Promise][13]&lt;[Array][14]&lt;any>>** all browser logs
Gets a cookie object by name.
If none provided gets all cookies.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let cookie = await I.grabCookie('auth');
Expand Down Expand Up @@ -659,6 +659,7 @@ Returns **[Promise][13]&lt;[string][9]>** HTML code for an element
### grabNumberOfOpenTabs
Grab number of open tabs.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let tabs = await I.grabNumberOfOpenTabs();
Expand All @@ -669,6 +670,7 @@ Returns **[Promise][13]&lt;[number][7]>** number of open tabs
### grabNumberOfVisibleElements
Grab number of visible elements by locator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let numOfElements = await I.grabNumberOfVisibleElements('p');
Expand Down Expand Up @@ -702,7 +704,7 @@ await I.grabPopupText();
### grabSource
Retrieves page source and returns it to test.
Resumes test execution, so should be used inside an async function.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let pageSource = await I.grabSource();
Expand Down
8 changes: 5 additions & 3 deletions docs/helpers/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ This action supports [React locators](https://codecept.io/react#locators)
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
An array as a result will be returned if there are more than one matched element.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let hint = await I.grabAttributeFrom('#tooltip', 'title');
Expand Down Expand Up @@ -769,7 +769,7 @@ Returns **[Promise][13]&lt;[Array][14]&lt;any>>**
Gets a cookie object by name.
If none provided gets all cookies.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let cookie = await I.grabCookie('auth');
Expand Down Expand Up @@ -886,6 +886,7 @@ Returns **[Promise][13]&lt;[string][8]>** HTML code for an element
### grabNumberOfOpenTabs
Grab number of open tabs.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let tabs = await I.grabNumberOfOpenTabs();
Expand All @@ -896,6 +897,7 @@ Returns **[Promise][13]&lt;[number][10]>** number of open tabs
### grabNumberOfVisibleElements
Grab number of visible elements by locator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let numOfElements = await I.grabNumberOfVisibleElements('p');
Expand Down Expand Up @@ -936,7 +938,7 @@ Returns **[Promise][13]&lt;([string][8] | null)>**
### grabSource
Retrieves page source and returns it to test.
Resumes test execution, so should be used inside an async function.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let pageSource = await I.grabSource();
Expand Down
7 changes: 4 additions & 3 deletions docs/helpers/TestCafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');

Retrieves an attribute from an element located by CSS or XPath and returns it to test.
An array as a result will be returned if there are more than one matched element.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let hint = await I.grabAttributeFrom('#tooltip', 'title');
Expand All @@ -431,7 +431,7 @@ console.log(JSON.stringify(logs))

Gets a cookie object by name.
If none provided gets all cookies.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let cookie = await I.grabCookie('auth');
Expand Down Expand Up @@ -459,6 +459,7 @@ Returns **[Promise][7]&lt;[string][4]>** current URL
### grabNumberOfVisibleElements

Grab number of visible elements by locator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let numOfElements = await I.grabNumberOfVisibleElements('p');
Expand All @@ -484,7 +485,7 @@ Returns **[Promise][7]&lt;[Object][5]&lt;[string][4], any>>** scroll position
### grabSource

Retrieves page source and returns it to test.
Resumes test execution, so should be used inside an async function.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let pageSource = await I.grabSource();
Expand Down
11 changes: 8 additions & 3 deletions docs/helpers/WebDriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ const windows = await I.grabAllWindowHandles();
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
An array as a result will be returned if there are more than one matched element.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let hint = await I.grabAttributeFrom('#tooltip', 'title');
Expand Down Expand Up @@ -953,7 +953,7 @@ Returns **[Promise][25]&lt;([string][19] | [undefined][27])>**
Gets a cookie object by name.
If none provided gets all cookies.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let cookie = await I.grabCookie('auth');
Expand Down Expand Up @@ -1034,11 +1034,14 @@ Returns **[object][18]** Element bounding rectangle
### grabGeoLocation
Return the current geo location
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let geoLocation = await I.grabGeoLocation();
```
Returns **[Promise][25]&lt;{latitude: [number][22], longitude: [number][22], altitude: [number][22]}>**
### grabHTMLFrom
Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
Expand All @@ -1059,6 +1062,7 @@ Returns **[Promise][25]&lt;[string][19]>** HTML code for an element
### grabNumberOfOpenTabs
Grab number of open tabs.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let tabs = await I.grabNumberOfOpenTabs();
Expand All @@ -1069,6 +1073,7 @@ Returns **[Promise][25]&lt;[number][22]>** number of open tabs
### grabNumberOfVisibleElements
Grab number of visible elements by locator.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let numOfElements = await I.grabNumberOfVisibleElements('p');
Expand Down Expand Up @@ -1102,7 +1107,7 @@ await I.grabPopupText();
### grabSource
Retrieves page source and returns it to test.
Resumes test execution, so should be used inside an async function.
Resumes test execution, so **should be used inside async function with `await`** operator.
```js
let pageSource = await I.grabSource();
Expand Down
2 changes: 1 addition & 1 deletion docs/webapi/grabAttributeFrom.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
An array as a result will be returned if there are more than one matched element.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let hint = await I.grabAttributeFrom('#tooltip', 'title');
Expand Down
2 changes: 1 addition & 1 deletion docs/webapi/grabCookie.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gets a cookie object by name.
If none provided gets all cookies.
Resumes test execution, so **should be used inside async with `await`** operator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let cookie = await I.grabCookie('auth');
Expand Down
4 changes: 3 additions & 1 deletion docs/webapi/grabGeoLocation.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Return the current geo location

Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let geoLocation = await I.grabGeoLocation();
```

@returns {Promise<{ latitude: number, longitude: number, altitude: number }>}
1 change: 1 addition & 0 deletions docs/webapi/grabNumberOfOpenTabs.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Grab number of open tabs.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let tabs = await I.grabNumberOfOpenTabs();
Expand Down
1 change: 1 addition & 0 deletions docs/webapi/grabNumberOfVisibleElements.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Grab number of visible elements by locator.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let numOfElements = await I.grabNumberOfVisibleElements('p');
Expand Down
2 changes: 1 addition & 1 deletion docs/webapi/grabSource.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Retrieves page source and returns it to test.
Resumes test execution, so should be used inside an async function.
Resumes test execution, so **should be used inside async function with `await`** operator.

```js
let pageSource = await I.grabSource();
Expand Down

0 comments on commit de8a82b

Please sign in to comment.