Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.6.3

* [stepByStepReport plugin] Fixed when using plugin with BeforeSuite. Fixes #2337 by @mirao
* [allure plugin] Fixed reporting of tests skipped by failure in before hook. Refer to #2349 & #2354. Fix by @koushikmohan1996

## 2.6.2

* [WebDriver][Puppeteer] Added `forceClick` method to emulate click event instead of using native events.
Expand Down
36 changes: 23 additions & 13 deletions docs/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,23 @@ Clicking the links is not what takes the most time during testing a web site. If

Let's submit this sample form for a test:

![](https://user-images.githubusercontent.com/220264/80355863-494a8280-8881-11ea-9b41-ba1f07abf094.png)

```html
<form method="post" action="/update" id="update_form">
<label for="user_name">Name</label>
<input type="text" name="user[name]" id="user_name" />
<input type="text" name="user[name]" id="user_name" /><br>
<label for="user_email">Email</label>
<input type="text" name="user[email]" id="user_email" />
<label for="user_gender">Gender</label>
<select id="user_gender" name="user[gender]">
<option value="m">Male</option>
<option value="f">Female</option>
</select>
<input type="submit" name="submitButton" value="Update" />
<input type="text" name="user[email]" id="user_email" /><br>
<label for="user_role">Role</label>
<select id="user_role" name="user[role]">
<option value="0">Admin</option>
<option value="1">User</option>
</select><br>
<input type="checkbox" id="accept" /> <label for="accept">Accept changes</label>
<div>
<input type="submit" name="submitButton" class="btn btn-primary" value="Save" />
</div>
</form>
```

Expand All @@ -178,24 +183,29 @@ I.fillField('Name', 'Miles');
// we can use input name
I.fillField('user[email]','miles@davis.com');
// select element by label, choose option by text
I.selectOption('Gender','Male');
// click 'Update' button, found by text
I.click('Update');
I.selectOption('Role','Admin');
// click 'Save' button, found by text
I.checkOption('Accept');
I.click('Save');
```

> ℹ `selectOption` works only with standard `<select>` <select placeholder="select"></select> HTML elements. If your selectbox is created by React, Vue, or as a component of any other framework, this method potentially won't work with it. Use `click` to manipulate it.

> ℹ `checkOption` also works only with standard `<input type="checkbox">` <input type="checkbox"> HTML elements. If your checkbox is created by React, Vue, or as a component of any other framework, this method potentially won't work with it. Use `click` to manipulate it.

Alternative scenario:

```js
// we are using CSS
I.fillField('#user_name', 'Miles');
I.fillField('#user_email','miles@davis.com');
// select element by label, option by value
I.selectOption('#user_gender','m');
I.selectOption('#user_role','1');
// click 'Update' button, found by name
I.click('submitButton', '#update_form');
```

To fill in sensitive data use the `secret` function:
To fill in sensitive data use the `secret` function, it won't expose actual value in logs.

```js
I.fillField('password', secret('123456'));
Expand Down
21 changes: 21 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ layout: Section

# Releases

## 2.6.2

* [WebDriver][Puppeteer] Added `forceClick` method to emulate click event instead of using native events.
* **[Playwright]** Updated to 0.14
* **[Puppeteer]** Updated to Puppeteer v3.0
* **[wdio]** Fixed undefined output directory for wdio plugns. Fix By **[PeterNgTr](https://github.com/PeterNgTr)**
* **[Playwright]** Introduced `handleDownloads` method to download file. Please note, this method has slightly different API than the same one in Puppeteer.
* **[allure]** Fixed undefined output directory for allure plugin on using custom runner. Fix by **[charliepradeep](https://github.com/charliepradeep)**
* **[WebDriver]** Fixed `waitForEnabled` fix for webdriver 6. Fix by **[dsharapkou](https://github.com/dsharapkou)**
* Workers: Fixed negative failure result if use scenario with the same names. Fix by **[Vorobeyko](https://github.com/Vorobeyko)**
* **[MockRequest]** Updated documentation to match new helper version
* Fixed: skipped tests are not reported if a suite failed in `before`. Refer [#2349](https://github.com/Codeception/CodeceptJS/issues/2349) & [#2354](https://github.com/Codeception/CodeceptJS/issues/2354). Fix by **[koushikmohan1996](https://github.com/koushikmohan1996)**

## 2.6.1

* [screenshotOnFail plugin] Fixed saving screenshot of active session.
* [screenshotOnFail plugin] Fix issue [#2301](https://github.com/Codeception/CodeceptJS/issues/2301) when having the flag `uniqueScreenshotNames`=true results in `undefined` in screenshot file name by **[PeterNgTr](https://github.com/PeterNgTr)**
* **[WebDriver]** Fixed `waitForElement` not applying the optional second argument to override the default timeout in webdriverio 6. Fix by **[Mooksc](https://github.com/Mooksc)**
* **[WebDriver]** Updated `waitUntil` method which is used by all of the wait* functions. This updates the `waitForElement` by the same convention used to update `waitForVisible` and `waitInUrl` to be compatible with both WebDriverIO v5 & v6. See [#2313](https://github.com/Codeception/CodeceptJS/issues/2313) by **[Mooksc](https://github.com/Mooksc)**

## 2.6.0

* **[Playwright] Updated to Playwright 0.12** by **[Georgegriff](https://github.com/Georgegriff)**.
Expand All @@ -29,6 +49,7 @@ I.executeScript(({x, y}) => x + y, {x, y});
* `click` - automatically waits for element to become clickable (visible, not animated) and waits for navigation.
* `clickLink` - deprecated
* `waitForClickable` - deprecated
* `forceClick` - added
* Added support for custom locators. See [#2277](https://github.com/Codeception/CodeceptJS/issues/2277)
* Introduced [device emulation](/playwright/#device-emulation):
* globally via `emulate` config option
Expand Down
36 changes: 35 additions & 1 deletion docs/helpers/Appium.md
Original file line number Diff line number Diff line change
Expand Up @@ -1162,12 +1162,14 @@ this.helpers['WebDriver']._locateCheckable('I agree with terms and conditions').
Find a clickable element by providing human readable text:

```js
this.helpers['WebDriver']._locateClickable('Next page').then // ...
const els = await this.helpers.WebDriver._locateClickable('Next page');
const els = await this.helpers.WebDriver._locateClickable('Next page', '.pages');
```

#### Parameters

- `locator` **([string][4] \| [object][6])** element located by CSS|XPath|strict locator.
- `context`

### \_locateFields

Expand Down Expand Up @@ -1211,6 +1213,38 @@ I.amOnPage('/login'); // opens a login page

- `url` **[string][4]** url path or global url.

### forceClick

Perform an emulated click on a link or a button, given by a locator.
Unlike normal click instead of sending native event, emulates a click with JavaScript.
This works on hidden, animated or inactive elements as well.

If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
For images, the "alt" attribute and inner text of any parent links are searched.

The second parameter is a context (CSS or XPath locator) to narrow the search.

```js
// simple link
I.forceClick('Logout');
// button of form
I.forceClick('Submit');
// CSS button
I.forceClick('#form input[type=submit]');
// XPath
I.forceClick('//form/*[@type=submit]');
// link in context
I.forceClick('Logout', '#nav');
// using strict locator
I.forceClick({css: 'nav a.login'});
```

#### Parameters

- `locator` **([string][4] \| [object][6])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
- `context` **([string][4]? | [object][6])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.{{ react }} (optional, default `null`)

### doubleClick

Performs a double-click on an element matched by link|button|label|CSS or XPath.
Expand Down
68 changes: 45 additions & 23 deletions docs/helpers/Playwright.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This helper should be configured in codecept.json or codecept.conf.js
- `keepBrowserState`: - keep browser state between tests when `restart` is set to false.
- `keepCookies`: - keep cookies between tests when `restart` is set to false.
- `waitForAction`: (optional) how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
- `waitForNavigation`: . When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle0`, `networkidle2`. See [Playwright API][2]. Array values are accepted as well.
- `waitForNavigation`: . When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle0`, `networkidle2`. Choose one of those options is possible. See [Playwright API][2].
- `pressKeyDelay`: . Delay between key presses in ms. Used when calling Playwrights page.type(...) in fillField/appendField
- `getPageTimeout` config option to set maximum navigation time in milliseconds.
- `waitForTimeout`: (optional) default wait* timeout in ms. Default: 1000.
Expand All @@ -63,15 +63,15 @@ This helper should be configured in codecept.json or codecept.conf.js
}
```

#### Example #2: Wait for DOMContentLoaded event and 0 network connections
#### Example #2: Wait for DOMContentLoaded event

```js
{
helpers: {
Playwright : {
url: "http://localhost",
restart: false,
waitForNavigation: [ "domcontentloaded", "networkidle0" ],
waitForNavigation: "domcontentloaded",
waitForAction: 500
}
}
Expand Down Expand Up @@ -890,6 +890,24 @@ let email = await I.grabValueFrom('input[name=email]');

Returns **[Promise][9]&lt;[string][7]>** attribute value

### handleDownloads

Handles a file download.Aa file name is required to save the file on disk.
Files are saved to "output" directory.

Should be used with [FileSystem helper][11] to check that file were downloaded correctly.

```js
I.handleDownloads('downloads/avatar.jpg');
I.click('Download Avatar');
I.amInPath('output/downloads');
I.waitForFile('downloads/avatar.jpg', 5);
```

#### Parameters

- `fileName` **[string][7]?** set filename for downloaded file

### haveRequestHeaders

Set headers for all next requests
Expand Down Expand Up @@ -928,7 +946,7 @@ Open new tab and switch to it
I.openNewTab();
```

You can pass in [page options][11] to emulate device on this page
You can pass in [page options][12] to emulate device on this page

```js
// enable mobile
Expand All @@ -943,7 +961,7 @@ I.openNewTab({ isMobile: true });

Presses a key in the browser (on a focused element).

_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][12].
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][13].

```js
I.pressKey('Backspace');
Expand Down Expand Up @@ -1002,13 +1020,13 @@ Some of the supported key names are:

#### Parameters

- `key` **([string][7] | [Array][10]&lt;[string][7]>)** key or array of keys to press._Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Playwright#1313][13]).
- `key` **([string][7] | [Array][10]&lt;[string][7]>)** key or array of keys to press._Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Playwright#1313][14]).

### pressKeyDown

Presses a key in the browser and leaves it in a down state.

To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][14]).
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][15]).

```js
I.pressKeyDown('Control');
Expand All @@ -1024,7 +1042,7 @@ I.pressKeyUp('Control');

Releases a key in the browser which was previously set to a down state.

To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][14]).
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][15]).

```js
I.pressKeyDown('Control');
Expand Down Expand Up @@ -1092,7 +1110,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
#### Parameters

- `fileName` **[string][7]** file name to save.
- `fullPage` **[boolean][15]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
- `fullPage` **[boolean][16]** (optional, `false` by default) flag to enable fullscreen screenshot mode.

### scrollPageToBottom

Expand Down Expand Up @@ -1541,7 +1559,7 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and

#### Parameters

- `fn` **([string][7] | [function][16])** to be executed in browser context.
- `fn` **([string][7] | [function][17])** to be executed in browser context.
- `argsOrSec` **([Array][10]&lt;any> | [number][8])?** (optional, `1` by default) arguments for function or seconds.
- `sec` **[number][8]?** (optional, `1` by default) time in seconds to wait

Expand All @@ -1563,7 +1581,7 @@ I.waitForInvisible('#popup');

Waits for navigation to finish. By default takes configured `waitForNavigation` option.

See [Pupeteer's reference][2]
See [Pupeteer's reference][18]

#### Parameters

Expand All @@ -1580,7 +1598,7 @@ I.waitForRequest(request => request.url() === 'http://example.com' && request.me

#### Parameters

- `urlOrPredicate` **([string][7] | [function][16])**
- `urlOrPredicate` **([string][7] | [function][17])**
- `sec` **[number][8]?** seconds to wait

### waitForResponse
Expand All @@ -1594,7 +1612,7 @@ I.waitForResponse(request => request.url() === 'http://example.com' && request.m

#### Parameters

- `urlOrPredicate` **([string][7] | [function][16])**
- `urlOrPredicate` **([string][7] | [function][17])**
- `sec` **[number][8]?** number of seconds to wait

### waitForText
Expand Down Expand Up @@ -1640,7 +1658,7 @@ I.waitForVisible('#popup');
#### Parameters

- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
- `sec` **[number][8]** (optional, `1` by default) time in seconds to waitThis method accepts [React selectors][17].
- `sec` **[number][8]** (optional, `1` by default) time in seconds to waitThis method accepts [React selectors][19].

### waitInUrl

Expand Down Expand Up @@ -1694,7 +1712,7 @@ I.waitUntil(() => window.requests == 0, 5);

#### Parameters

- `fn` **([function][16] | [string][7])** function which is executed in browser context.
- `fn` **([function][17] | [string][7])** function which is executed in browser context.
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
- `timeoutMsg` **[string][7]** message to show in case of timeout fail.
- `interval` **[number][8]?**
Expand All @@ -1715,7 +1733,7 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');

[1]: https://github.com/microsoft/playwright

[2]: https://github.com/GoogleChrome/Playwright/blob/master/docs/api.md#pagewaitfornavigationoptions
[2]: https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitfornavigationoptions

[3]: https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target

Expand All @@ -1733,16 +1751,20 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[11]: https://github.com/microsoft/playwright/blob/v0.12.1/docs/api.md#browsernewpageoptions
[11]: https://codecept.io/helpers/FileSystem

[12]: https://github.com/microsoft/playwright/blob/v0.12.1/docs/api.md#browsernewpageoptions

[13]: #fillfield

[12]: #fillfield
[14]: https://github.com/GoogleChrome/Playwright/issues/1313

[13]: https://github.com/GoogleChrome/Playwright/issues/1313
[15]: #click

[14]: #click
[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[18]: https://github.com/GoogleChrome/Playwright/blob/master/docs/api.md#pagewaitfornavigationoptions

[17]: https://codecept.io/react
[19]: https://codecept.io/react
Loading