codeceptjs 2.4.3 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +117 -0
- package/README.md +32 -7
- package/bin/codecept.js +3 -0
- package/docs/basics.md +11 -5
- package/docs/bdd.md +4 -4
- package/docs/build/MockRequest.js +3 -0
- package/docs/build/Nightmare.js +10 -2
- package/docs/build/Playwright.js +3187 -0
- package/docs/build/Protractor.js +16 -2
- package/docs/build/Puppeteer.js +126 -19
- package/docs/build/REST.js +3 -1
- package/docs/build/TestCafe.js +11 -3
- package/docs/build/WebDriver.js +361 -28
- package/docs/changelog.md +116 -0
- package/docs/configuration.md +2 -2
- package/docs/custom-helpers.md +55 -10
- package/docs/helpers/Appium.md +81 -1
- package/docs/helpers/MockRequest.md +281 -38
- package/docs/helpers/Nightmare.md +10 -2
- package/docs/helpers/Playwright.md +1770 -0
- package/docs/helpers/Protractor.md +15 -3
- package/docs/helpers/Puppeteer-firefox.md +32 -1
- package/docs/helpers/Puppeteer.md +126 -76
- package/docs/helpers/TestCafe.md +10 -2
- package/docs/helpers/WebDriver.md +208 -118
- package/docs/locators.md +2 -0
- package/docs/playwright.md +306 -0
- package/docs/plugins.md +103 -0
- package/docs/reports.md +12 -0
- package/docs/shadow.md +68 -0
- package/docs/visual.md +0 -73
- package/docs/webapi/forceClick.mustache +27 -0
- package/docs/webapi/seeInPopup.mustache +7 -0
- package/docs/webapi/setCookie.mustache +10 -2
- package/docs/webapi/type.mustache +12 -0
- package/docs/webdriver.md +7 -3
- package/lib/codecept.js +1 -1
- package/lib/command/definitions.js +2 -2
- package/lib/command/generate.js +4 -4
- package/lib/command/gherkin/snippets.js +4 -4
- package/lib/command/init.js +1 -1
- package/lib/command/interactive.js +3 -0
- package/lib/command/run-multiple.js +2 -2
- package/lib/command/run-rerun.js +2 -0
- package/lib/command/run-workers.js +22 -8
- package/lib/command/run.js +2 -0
- package/lib/command/workers/runTests.js +1 -0
- package/lib/container.js +1 -1
- package/lib/event.js +2 -0
- package/lib/helper/MockRequest.js +3 -0
- package/lib/helper/Playwright.js +2422 -0
- package/lib/helper/Protractor.js +1 -2
- package/lib/helper/Puppeteer.js +84 -19
- package/lib/helper/REST.js +3 -1
- package/lib/helper/TestCafe.js +1 -1
- package/lib/helper/WebDriver.js +313 -26
- package/lib/helper/extras/PlaywrightPropEngine.js +53 -0
- package/lib/helper/scripts/isElementClickable.js +54 -14
- package/lib/interfaces/gherkin.js +1 -1
- package/lib/listener/helpers.js +3 -0
- package/lib/locator.js +5 -0
- package/lib/mochaFactory.js +12 -10
- package/lib/plugin/allure.js +8 -1
- package/lib/plugin/autoDelay.js +1 -8
- package/lib/plugin/commentStep.js +133 -0
- package/lib/plugin/screenshotOnFail.js +3 -10
- package/lib/plugin/selenoid.js +2 -2
- package/lib/plugin/standardActingHelpers.js +13 -0
- package/lib/plugin/stepByStepReport.js +1 -8
- package/lib/plugin/wdio.js +10 -1
- package/lib/reporter/cli.js +30 -1
- package/lib/session.js +7 -4
- package/package.json +13 -10
- package/typings/Mocha.d.ts +567 -16
- package/typings/index.d.ts +9 -5
- package/typings/types.d.ts +1634 -74
package/docs/changelog.md
CHANGED
|
@@ -7,6 +7,122 @@ layout: Section
|
|
|
7
7
|
|
|
8
8
|
# Releases
|
|
9
9
|
|
|
10
|
+
## 2.6.2
|
|
11
|
+
|
|
12
|
+
* [WebDriver][Puppeteer] Added `forceClick` method to emulate click event instead of using native events.
|
|
13
|
+
* **[Playwright]** Updated to 0.14
|
|
14
|
+
* **[Puppeteer]** Updated to Puppeteer v3.0
|
|
15
|
+
* **[wdio]** Fixed undefined output directory for wdio plugns. Fix By **[PeterNgTr](https://github.com/PeterNgTr)**
|
|
16
|
+
* **[Playwright]** Introduced `handleDownloads` method to download file. Please note, this method has slightly different API than the same one in Puppeteer.
|
|
17
|
+
* **[allure]** Fixed undefined output directory for allure plugin on using custom runner. Fix by **[charliepradeep](https://github.com/charliepradeep)**
|
|
18
|
+
* **[WebDriver]** Fixed `waitForEnabled` fix for webdriver 6. Fix by **[dsharapkou](https://github.com/dsharapkou)**
|
|
19
|
+
* Workers: Fixed negative failure result if use scenario with the same names. Fix by **[Vorobeyko](https://github.com/Vorobeyko)**
|
|
20
|
+
* **[MockRequest]** Updated documentation to match new helper version
|
|
21
|
+
* 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)**
|
|
22
|
+
|
|
23
|
+
## 2.6.1
|
|
24
|
+
|
|
25
|
+
* [screenshotOnFail plugin] Fixed saving screenshot of active session.
|
|
26
|
+
* [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)**
|
|
27
|
+
* **[WebDriver]** Fixed `waitForElement` not applying the optional second argument to override the default timeout in webdriverio 6. Fix by **[Mooksc](https://github.com/Mooksc)**
|
|
28
|
+
* **[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)**
|
|
29
|
+
|
|
30
|
+
## 2.6.0
|
|
31
|
+
|
|
32
|
+
* **[Playwright] Updated to Playwright 0.12** by **[Georgegriff](https://github.com/Georgegriff)**.
|
|
33
|
+
|
|
34
|
+
Upgrade playwright to ^0.12:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
npm i playwright@^0.12 --save
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
[Notable changes](https://github.com/microsoft/playwright/releases/tag/v0.12.0):
|
|
41
|
+
* Fixed opening two browsers on start
|
|
42
|
+
* `executeScript` - passed function now accepts only one argument. Pass in objects or arrays if you need multtple arguments:
|
|
43
|
+
```js
|
|
44
|
+
// Old style, does not work anymore:
|
|
45
|
+
I.executeScript((x, y) => x + y, x, y);
|
|
46
|
+
// New style, passing an object:
|
|
47
|
+
I.executeScript(({x, y}) => x + y, {x, y});
|
|
48
|
+
```
|
|
49
|
+
* `click` - automatically waits for element to become clickable (visible, not animated) and waits for navigation.
|
|
50
|
+
* `clickLink` - deprecated
|
|
51
|
+
* `waitForClickable` - deprecated
|
|
52
|
+
* `forceClick` - added
|
|
53
|
+
* Added support for custom locators. See [#2277](https://github.com/Codeception/CodeceptJS/issues/2277)
|
|
54
|
+
* Introduced [device emulation](/playwright/#device-emulation):
|
|
55
|
+
* globally via `emulate` config option
|
|
56
|
+
* per session
|
|
57
|
+
|
|
58
|
+
**[WebDriver] Updated to webdriverio v6** by **[PeterNgTr](https://github.com/PeterNgTr)**.
|
|
59
|
+
|
|
60
|
+
Read [release notes](https://webdriver.io/blog/2020/03/26/webdriverio-v6-released.html), then
|
|
61
|
+
upgrade webdriverio to ^6.0:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
npm i webdriverio@^6.0 --save
|
|
65
|
+
```
|
|
66
|
+
*(webdriverio v5 support is deprecated and will be removed in CodeceptJS 3.0)*
|
|
67
|
+
**[WebDriver]** Introduced [Shadow DOM support](/shadow) by **[gkushang](https://github.com/gkushang)**
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
I.click({ shadow: ['my-app', 'recipe-hello', 'button'] });
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
* **Fixed parallel execution of `run-workers` for Gherkin** scenarios by **[koushikmohan1996](https://github.com/koushikmohan1996)**
|
|
74
|
+
* **[MockRequest]** Updated and **moved to [standalone package](https://github.com/codecept-js/mock-request)**:
|
|
75
|
+
* full support for record/replay mode for Puppeteer
|
|
76
|
+
* added `mockServer` method to use flexible PollyJS API to define mocks
|
|
77
|
+
* fixed stale browser screen in record mode.
|
|
78
|
+
* **[Playwright]** Added support on for `screenshotOnFail` plugin by **[amonkc](https://github.com/amonkc)**
|
|
79
|
+
* Gherkin improvement: setting different tags per examples. See [#2208](https://github.com/Codeception/CodeceptJS/issues/2208) by **[acuper](https://github.com/acuper)**
|
|
80
|
+
* **[TestCafe]** Updated `click` to take first visible element. Fixes [#2226](https://github.com/Codeception/CodeceptJS/issues/2226) by **[theTainted](https://github.com/theTainted)**
|
|
81
|
+
* [Puppeteer][WebDriver] Updated `waitForClickable` method to check for element overlapping. See [#2261](https://github.com/Codeception/CodeceptJS/issues/2261) by **[PiQx](https://github.com/PiQx)**
|
|
82
|
+
* **[Puppeteer]** Dropped `puppeteer-firefox` support, as Puppeteer supports Firefox natively.
|
|
83
|
+
* **[REST]** Rrespect Content-Type header. See [#2262](https://github.com/Codeception/CodeceptJS/issues/2262) by **[pmarshall-legacy](https://github.com/pmarshall-legacy)**
|
|
84
|
+
* [allure plugin] Fixes BeforeSuite failures in allure reports. See [#2248](https://github.com/Codeception/CodeceptJS/issues/2248) by **[Georgegriff](https://github.com/Georgegriff)**
|
|
85
|
+
* [WebDriver][Puppeteer][Playwright] A screenshot of for an active session is saved in multi-session mode. See [#2253](https://github.com/Codeception/CodeceptJS/issues/2253) by **[ChexWarrior](https://github.com/ChexWarrior)**
|
|
86
|
+
* Fixed `--profile` option by **[pablopaul](https://github.com/pablopaul)**. Profile value to be passed into `run-multiple` and `run-workers`:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
npx codecept run-workers 2 --profile firefox
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Value is available at `process.env.profile` (previously `process.profile`). See [#2302](https://github.com/Codeception/CodeceptJS/issues/2302). Fixes [#1968](https://github.com/Codeception/CodeceptJS/issues/1968) [#1315](https://github.com/Codeception/CodeceptJS/issues/1315)
|
|
93
|
+
|
|
94
|
+
* [commentStep Plugin introduced](/plugins#commentstep). Allows to annotate logical parts of a test:
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
__`Given`;
|
|
98
|
+
I.amOnPage('/profile')
|
|
99
|
+
|
|
100
|
+
__`When`;
|
|
101
|
+
I.click('Logout');
|
|
102
|
+
|
|
103
|
+
__`Then`;
|
|
104
|
+
I.see('You are logged out');
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 2.5.0
|
|
108
|
+
|
|
109
|
+
* **Experimental: [Playwright](/playwright) helper introduced**.
|
|
110
|
+
|
|
111
|
+
> [Playwright](https://github.com/microsoft/playwright/) is an alternative to Puppeteer which works very similarly to it but adds cross-browser support with Firefox and Webkit. Until v1.0 Playwright API is not stable but we introduce it to CodeceptJS so you could try it.
|
|
112
|
+
|
|
113
|
+
* **[Puppeteer]** Fixed basic auth support when running in multiple sessions. See [#2178](https://github.com/Codeception/CodeceptJS/issues/2178) by **[ian-bartholomew](https://github.com/ian-bartholomew)**
|
|
114
|
+
* **[Puppeteer]** Fixed `waitForText` when there is no `body` element on page (redirect). See [#2181](https://github.com/Codeception/CodeceptJS/issues/2181) by **[Vorobeyko](https://github.com/Vorobeyko)**
|
|
115
|
+
* [Selenoid plugin] Fixed overriding current capabilities by adding deepMerge. Fixes [#2183](https://github.com/Codeception/CodeceptJS/issues/2183) by **[koushikmohan1996](https://github.com/koushikmohan1996)**
|
|
116
|
+
* Added types for `Scenario.todo` by **[Vorobeyko](https://github.com/Vorobeyko)**
|
|
117
|
+
* Added types for Mocha by **[Vorobeyko](https://github.com/Vorobeyko)**. Fixed typing conflicts with Jest
|
|
118
|
+
* **[FileSystem]** Added methods by **[nitschSB](https://github.com/nitschSB)**
|
|
119
|
+
* `waitForFile`
|
|
120
|
+
* `seeFileContentsEqualReferenceFile`
|
|
121
|
+
* Added `--colors` option to `run` and `run-multiple` so you force colored output in dockerized environment. See [#2189](https://github.com/Codeception/CodeceptJS/issues/2189) by **[mirao](https://github.com/mirao)**
|
|
122
|
+
* **[WebDriver]** Added `type` command to enter value without focusing on a field. See [#2198](https://github.com/Codeception/CodeceptJS/issues/2198) by **[xMutaGenx](https://github.com/xMutaGenx)**
|
|
123
|
+
* Fixed `codeceptjs gt` command to respect config pattern for tests. See [#2200](https://github.com/Codeception/CodeceptJS/issues/2200) and [#2204](https://github.com/Codeception/CodeceptJS/issues/2204) by **[matheo](https://github.com/matheo)**
|
|
124
|
+
|
|
125
|
+
|
|
10
126
|
## 2.4.3
|
|
11
127
|
|
|
12
128
|
* Hotfix for interactive pause
|
package/docs/configuration.md
CHANGED
|
@@ -118,7 +118,7 @@ exports.config = {
|
|
|
118
118
|
|
|
119
119
|
## Profile
|
|
120
120
|
|
|
121
|
-
Using
|
|
121
|
+
Using `process.env.profile` you can change the config dynamically.
|
|
122
122
|
It provides value of `--profile` option passed to runner.
|
|
123
123
|
Use its value to change config value on the fly.
|
|
124
124
|
|
|
@@ -134,7 +134,7 @@ exports.config = {
|
|
|
134
134
|
WebDriver: {
|
|
135
135
|
url: 'http://localhost:3000',
|
|
136
136
|
// load value from `profile`
|
|
137
|
-
browser: process.profile || 'firefox'
|
|
137
|
+
browser: process.env.profile || 'firefox'
|
|
138
138
|
|
|
139
139
|
}
|
|
140
140
|
}
|
package/docs/custom-helpers.md
CHANGED
|
@@ -3,12 +3,13 @@ permalink: /helpers
|
|
|
3
3
|
title: Custom Helpers
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
# Extending CodeceptJS With Custom Helpers
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Helper is the core concept of CodeceptJS. Helper is a wrapper on top of various libraries providing unified interface around them.
|
|
8
9
|
|
|
9
|
-
Methods of Helper class will be available in tests in `I` object. This abstracts test scenarios from the implementation and allows
|
|
10
|
+
Methods of Helper class will be available in tests in `I` object. This abstracts test scenarios from the implementation and allows switching between backends seamlessly.
|
|
10
11
|
|
|
11
|
-
Functionality of CodeceptJS
|
|
12
|
+
Functionality of CodeceptJS could be extended by writing custom helpers.
|
|
12
13
|
|
|
13
14
|
Helpers can also be installed as Node packages and required by corresponding Node modules.
|
|
14
15
|
|
|
@@ -36,7 +37,7 @@ helpers: {
|
|
|
36
37
|
```
|
|
37
38
|
|
|
38
39
|
Helpers are ES6 classes inherited from [corresponding abstract class](https://github.com/Codeception/CodeceptJS/blob/master/lib/helper.js).
|
|
39
|
-
Generated Helper will be added to `codecept.conf.js` config. It should look like this:
|
|
40
|
+
Generated Helper will be added to `codecept.conf.js` config file. It should look like this:
|
|
40
41
|
|
|
41
42
|
```js
|
|
42
43
|
const Helper = codecept_helper;
|
|
@@ -112,7 +113,7 @@ module.exports = MyHelper;
|
|
|
112
113
|
|
|
113
114
|
## Puppeteer Example
|
|
114
115
|
|
|
115
|
-
Puppeteer has [nice and elegant API](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md) which you can use inside helpers.
|
|
116
|
+
Puppeteer has [nice and elegant API](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md) which you can use inside helpers. Accessing `page` instance via `this.helpers.Puppeteer.page` from inside a helper.
|
|
116
117
|
|
|
117
118
|
Let's see how we can use [emulate](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pageemulateoptions) function to emulate iPhone browser in a test.
|
|
118
119
|
|
|
@@ -168,6 +169,50 @@ class MyHelper extends Helper {
|
|
|
168
169
|
module.exports = MyHelper;
|
|
169
170
|
```
|
|
170
171
|
|
|
172
|
+
## Accessing Elements
|
|
173
|
+
|
|
174
|
+
WebDriver, Puppeteer, Playwright, and Protractor drivers provide API for web elements.
|
|
175
|
+
However, CodeceptJS do not expose them to tests by design, keeping test to be action focused.
|
|
176
|
+
If you need to get access to web elements, it is recommended to implement operations for web elements in a custom helper.
|
|
177
|
+
|
|
178
|
+
To get access for elements, connect to a corresponding helper and use `_locate` function to match web elements by CSS or XPath, like you usually do:
|
|
179
|
+
|
|
180
|
+
### Acessing Elements in WebDriver
|
|
181
|
+
|
|
182
|
+
```js
|
|
183
|
+
// inside a custom helper
|
|
184
|
+
async clickOnEveryElement(locator) {
|
|
185
|
+
const { WebDriver } = this.helpers;
|
|
186
|
+
const els = await WebDriver._locate(locator);
|
|
187
|
+
|
|
188
|
+
for (let el of els) {
|
|
189
|
+
await el.click();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
In this case an an instance of webdriverio element is used.
|
|
194
|
+
To get a [complete API of an element](https://webdriver.io/docs/api/) refer to webdriverio docs.
|
|
195
|
+
|
|
196
|
+
### Accessing Elements in Playwright & Puppeteer
|
|
197
|
+
|
|
198
|
+
Similar method can be implemented for Playwright & Puppeteer:
|
|
199
|
+
|
|
200
|
+
```js
|
|
201
|
+
// inside a custom helper
|
|
202
|
+
async clickOnEveryElement(locator) {
|
|
203
|
+
const { Playwright } = this.helpers;
|
|
204
|
+
const els = await Playwright._locate(locator);
|
|
205
|
+
|
|
206
|
+
for (let el of els) {
|
|
207
|
+
await el.click();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
In this case `el` will be an instance of [ElementHandle](https://github.com/microsoft/playwright/blob/v0.12.1/docs/api.md#class-elementhandle) which is similar for Playwright & [Puppeteer](https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-elementhandle).
|
|
213
|
+
|
|
214
|
+
> ℹ There are more `_locate*` methods in each helper. Take a look on documentation of a helper you use to see which exact method it exposes.
|
|
215
|
+
|
|
171
216
|
## Configuration
|
|
172
217
|
|
|
173
218
|
Helpers should be enabled inside `codecept.json` or `codecept.conf.js` files. Command `generate helper`
|
|
@@ -175,13 +220,13 @@ does that for you, however you can enable them manually by placing helper to `he
|
|
|
175
220
|
You can also pass additional config options to your helper from a config - **(please note, this example contains comments, while JSON format doesn't support them)**:
|
|
176
221
|
|
|
177
222
|
```js
|
|
178
|
-
|
|
223
|
+
helpers: {
|
|
179
224
|
// here goes standard helpers:
|
|
180
225
|
// WebDriver, Protractor, Nightmare, etc...
|
|
181
226
|
// and their configuration
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
227
|
+
MyHelper: {
|
|
228
|
+
require: "./my_helper.js", // path to module
|
|
229
|
+
defaultHost: "http://mysite.com" // custom config param
|
|
185
230
|
}
|
|
186
231
|
|
|
187
232
|
}
|
|
@@ -282,4 +327,4 @@ Retry rules are available in array `recorder.retries`. The last retry rule can b
|
|
|
282
327
|
|
|
283
328
|
## Using Typescript
|
|
284
329
|
|
|
285
|
-
|
|
330
|
+
With Typescript, just simply replacing `module.exports` with `export` for autocompletion.
|
package/docs/helpers/Appium.md
CHANGED
|
@@ -1107,6 +1107,30 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
|
1107
1107
|
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait (optional, default `1`)
|
|
1108
1108
|
- `context` **([string][4] \| [object][6])?** (optional) element located by CSS|XPath|strict locator. (optional, default `null`)
|
|
1109
1109
|
|
|
1110
|
+
### \_isShadowLocator
|
|
1111
|
+
|
|
1112
|
+
Check if locator is type of "Shadow"
|
|
1113
|
+
|
|
1114
|
+
#### Parameters
|
|
1115
|
+
|
|
1116
|
+
- `locator` **[object][6]**
|
|
1117
|
+
|
|
1118
|
+
### \_locateShadow
|
|
1119
|
+
|
|
1120
|
+
Locate Element within the Shadow Dom
|
|
1121
|
+
|
|
1122
|
+
#### Parameters
|
|
1123
|
+
|
|
1124
|
+
- `locator` **[object][6]**
|
|
1125
|
+
|
|
1126
|
+
### \_smartWait
|
|
1127
|
+
|
|
1128
|
+
Smart Wait to locate an element
|
|
1129
|
+
|
|
1130
|
+
#### Parameters
|
|
1131
|
+
|
|
1132
|
+
- `locator` **[object][6]**
|
|
1133
|
+
|
|
1110
1134
|
### \_locate
|
|
1111
1135
|
|
|
1112
1136
|
Get elements by different locator types, including strict locator.
|
|
@@ -1138,12 +1162,14 @@ this.helpers['WebDriver']._locateCheckable('I agree with terms and conditions').
|
|
|
1138
1162
|
Find a clickable element by providing human readable text:
|
|
1139
1163
|
|
|
1140
1164
|
```js
|
|
1141
|
-
this.helpers
|
|
1165
|
+
const els = await this.helpers.WebDriver._locateClickable('Next page');
|
|
1166
|
+
const els = await this.helpers.WebDriver._locateClickable('Next page', '.pages');
|
|
1142
1167
|
```
|
|
1143
1168
|
|
|
1144
1169
|
#### Parameters
|
|
1145
1170
|
|
|
1146
1171
|
- `locator` **([string][4] \| [object][6])** element located by CSS|XPath|strict locator.
|
|
1172
|
+
- `context`
|
|
1147
1173
|
|
|
1148
1174
|
### \_locateFields
|
|
1149
1175
|
|
|
@@ -1187,6 +1213,38 @@ I.amOnPage('/login'); // opens a login page
|
|
|
1187
1213
|
|
|
1188
1214
|
- `url` **[string][4]** url path or global url.
|
|
1189
1215
|
|
|
1216
|
+
### forceClick
|
|
1217
|
+
|
|
1218
|
+
Perform an emulated click on a link or a button, given by a locator.
|
|
1219
|
+
Unlike normal click instead of sending native event, emulates a click with JavaScript.
|
|
1220
|
+
This works on hidden, animated or inactive elements as well.
|
|
1221
|
+
|
|
1222
|
+
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
1223
|
+
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
1224
|
+
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
1225
|
+
|
|
1226
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
1227
|
+
|
|
1228
|
+
```js
|
|
1229
|
+
// simple link
|
|
1230
|
+
I.forceClick('Logout');
|
|
1231
|
+
// button of form
|
|
1232
|
+
I.forceClick('Submit');
|
|
1233
|
+
// CSS button
|
|
1234
|
+
I.forceClick('#form input[type=submit]');
|
|
1235
|
+
// XPath
|
|
1236
|
+
I.forceClick('//form/*[@type=submit]');
|
|
1237
|
+
// link in context
|
|
1238
|
+
I.forceClick('Logout', '#nav');
|
|
1239
|
+
// using strict locator
|
|
1240
|
+
I.forceClick({css: 'nav a.login'});
|
|
1241
|
+
```
|
|
1242
|
+
|
|
1243
|
+
#### Parameters
|
|
1244
|
+
|
|
1245
|
+
- `locator` **([string][4] \| [object][6])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1246
|
+
- `context` **([string][4]? | [object][6])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.{{ react }} (optional, default `null`)
|
|
1247
|
+
|
|
1190
1248
|
### doubleClick
|
|
1191
1249
|
|
|
1192
1250
|
Performs a double-click on an element matched by link|button|label|CSS or XPath.
|
|
@@ -1477,6 +1535,8 @@ I.moveCursorTo('#submit', 5,5);
|
|
|
1477
1535
|
#### Parameters
|
|
1478
1536
|
|
|
1479
1537
|
- `locator` **([string][4] \| [object][6])** located by CSS|XPath|strict locator.
|
|
1538
|
+
- `xOffset`
|
|
1539
|
+
- `yOffset`
|
|
1480
1540
|
- `offsetX` **[number][8]** (optional, `0` by default) X-axis offset. (optional, default `0`)
|
|
1481
1541
|
- `offsetY` **[number][8]** (optional, `0` by default) Y-axis offset. (optional, default `0`)
|
|
1482
1542
|
|
|
@@ -1496,6 +1556,24 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
|
|
|
1496
1556
|
- `fileName` **[string][4]** file name to save.
|
|
1497
1557
|
- `fullPage` **[boolean][15]** (optional, `false` by default) flag to enable fullscreen screenshot mode. (optional, default `false`)
|
|
1498
1558
|
|
|
1559
|
+
### type
|
|
1560
|
+
|
|
1561
|
+
Types out the given string or the array of keys provided.
|
|
1562
|
+
_Note:_ Should only be used when using [`fillField`][19] is not an option.
|
|
1563
|
+
|
|
1564
|
+
```js
|
|
1565
|
+
// When passing in a string
|
|
1566
|
+
I.type('Type this out.');
|
|
1567
|
+
// When passing in an array
|
|
1568
|
+
I.type(['T', 'E', 'X', 'T']);
|
|
1569
|
+
```
|
|
1570
|
+
|
|
1571
|
+
#### Parameters
|
|
1572
|
+
|
|
1573
|
+
- `keys`
|
|
1574
|
+
- `key` **([string][4] \| [Array][14]<[string][4]>)** or array of keys to type.
|
|
1575
|
+
Type out given array of keys or a string of text
|
|
1576
|
+
|
|
1499
1577
|
### dragAndDrop
|
|
1500
1578
|
|
|
1501
1579
|
Drag an item to a destination element.
|
|
@@ -1705,3 +1783,5 @@ Returns **[object][6]** Element bounding rectangle
|
|
|
1705
1783
|
[17]: https://webdriver.io/docs/timeouts.html
|
|
1706
1784
|
|
|
1707
1785
|
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
|
|
1786
|
+
|
|
1787
|
+
[19]: #fillfield
|