webdriverio 5.8.5 → 5.9.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/build/commands/browser/react$$.js +2 -2
- package/build/commands/browser/react$.js +2 -2
- package/build/commands/element/react$$.js +48 -0
- package/build/commands/element/react$.js +52 -0
- package/build/scripts/resq.js +4 -4
- package/package.json +7 -7
- package/webdriverio-core.d.ts +14 -10
- package/webdriverio.d.ts +9 -1
|
@@ -31,9 +31,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
31
31
|
* </example>
|
|
32
32
|
*
|
|
33
33
|
* @alias browser.react$$
|
|
34
|
-
* @param {String
|
|
34
|
+
* @param {String} selector of React component
|
|
35
35
|
* @param {Object=} props React props the element should contain
|
|
36
|
-
* @param {
|
|
36
|
+
* @param {Array<any>|number|string|object|boolean=} state React state the element should be in
|
|
37
37
|
* @return {Element[]}
|
|
38
38
|
*
|
|
39
39
|
*/
|
|
@@ -35,9 +35,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
35
35
|
* </example>
|
|
36
36
|
*
|
|
37
37
|
* @alias browser.react$
|
|
38
|
-
* @param {String
|
|
38
|
+
* @param {String} selector of React component
|
|
39
39
|
* @param {Object=} props React props the element should contain
|
|
40
|
-
* @param {
|
|
40
|
+
* @param {Array<any>|number|string|object|boolean=} state React state the element should be in
|
|
41
41
|
* @return {Element}
|
|
42
42
|
*
|
|
43
43
|
*/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = react$$;
|
|
7
|
+
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
|
|
10
|
+
var _getElementObject = require("../../utils/getElementObject");
|
|
11
|
+
|
|
12
|
+
var _resq = require("../../scripts/resq");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* The `react$$` command is a useful command to query multiple React Components
|
|
19
|
+
* by their actual name and filter them by props and state.
|
|
20
|
+
*
|
|
21
|
+
* **NOTE:** the command only works with applications using React v16.x
|
|
22
|
+
*
|
|
23
|
+
* <example>
|
|
24
|
+
:pause.js
|
|
25
|
+
it('should calculate 7 * 6', () => {
|
|
26
|
+
browser.url('https://ahfarmer.github.io/calculator/');
|
|
27
|
+
const appWrapper = browser.$('div#root')
|
|
28
|
+
|
|
29
|
+
const orangeButtons = appWrapper.react$$('t', { orange: true })
|
|
30
|
+
console.log(orangeButtons.map((btn) => btn.getText())); // prints "[ '÷', 'x', '-', '+', '=' ]"
|
|
31
|
+
});
|
|
32
|
+
* </example>
|
|
33
|
+
*
|
|
34
|
+
* @alias react$$
|
|
35
|
+
* @param {String} selector of React component
|
|
36
|
+
* @param {Object=} props React props the element should contain
|
|
37
|
+
* @param {Array<any>|number|string|object|boolean=} state React state the element should be in
|
|
38
|
+
* @return {Element[]}
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
const resqScript = _fs.default.readFileSync(require.resolve('resq'));
|
|
42
|
+
|
|
43
|
+
async function react$$(selector, props = {}, state = {}) {
|
|
44
|
+
await this.executeScript(resqScript.toString(), []);
|
|
45
|
+
await this.execute(_resq.waitToLoadReact);
|
|
46
|
+
const res = await this.execute(_resq.react$$, selector, props, state, this);
|
|
47
|
+
return _getElementObject.getElements.call(this, selector, res);
|
|
48
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = react$;
|
|
7
|
+
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
|
|
10
|
+
var _getElementObject = require("../../utils/getElementObject");
|
|
11
|
+
|
|
12
|
+
var _resq = require("../../scripts/resq");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* The `react$` command is a useful command to query React Components by their
|
|
19
|
+
* actual name and filter them by props and state.
|
|
20
|
+
*
|
|
21
|
+
* **NOTE:** the command only works with applications using React v16.x
|
|
22
|
+
*
|
|
23
|
+
* <example>
|
|
24
|
+
:pause.js
|
|
25
|
+
it('should calculate 7 * 6', () => {
|
|
26
|
+
browser.url('https://ahfarmer.github.io/calculator/');
|
|
27
|
+
const appWrapper = browser.$('div#root')
|
|
28
|
+
|
|
29
|
+
appWrapper.react$('t', { name: '7' }).click()
|
|
30
|
+
appWrapper.react$('t', { name: 'x' }).click()
|
|
31
|
+
appWrapper.react$('t', { name: '6' }).click()
|
|
32
|
+
appWrapper.react$('t', { name: '=' }).click()
|
|
33
|
+
|
|
34
|
+
console.log($('.component-display').getText()); // prints "42"
|
|
35
|
+
});
|
|
36
|
+
* </example>
|
|
37
|
+
*
|
|
38
|
+
* @alias react$
|
|
39
|
+
* @param {String} selector of React component
|
|
40
|
+
* @param {Object=} props React props the element should contain
|
|
41
|
+
* @param {Array<any>|number|string|object|boolean=} state React state the element should be in
|
|
42
|
+
* @return {Element}
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
const resqScript = _fs.default.readFileSync(require.resolve('resq'));
|
|
46
|
+
|
|
47
|
+
async function react$(selector, props = {}, state = {}) {
|
|
48
|
+
await this.executeScript(resqScript.toString(), []);
|
|
49
|
+
await this.execute(_resq.waitToLoadReact);
|
|
50
|
+
const res = await this.execute(_resq.react$, selector, props, state, this);
|
|
51
|
+
return _getElementObject.getElement.call(this, selector, res);
|
|
52
|
+
}
|
package/build/scripts/resq.js
CHANGED
|
@@ -11,8 +11,8 @@ const waitToLoadReact = function waitToLoadReact() {
|
|
|
11
11
|
|
|
12
12
|
exports.waitToLoadReact = waitToLoadReact;
|
|
13
13
|
|
|
14
|
-
const react$ = function react$(selector, props = {}, state = {}) {
|
|
15
|
-
let element = window.resq.resq$(selector);
|
|
14
|
+
const react$ = function react$(selector, props = {}, state = {}, reactElement) {
|
|
15
|
+
let element = window.resq.resq$(selector, reactElement);
|
|
16
16
|
|
|
17
17
|
if (Object.keys(props).length) {
|
|
18
18
|
element = element.byProps(props);
|
|
@@ -35,8 +35,8 @@ const react$ = function react$(selector, props = {}, state = {}) {
|
|
|
35
35
|
|
|
36
36
|
exports.react$ = react$;
|
|
37
37
|
|
|
38
|
-
const react$$ = function react$$(selector, props, state) {
|
|
39
|
-
let elements = window.resq.resq$$(selector);
|
|
38
|
+
const react$$ = function react$$(selector, props, state, reactElement) {
|
|
39
|
+
let elements = window.resq.resq$$(selector, reactElement);
|
|
40
40
|
|
|
41
41
|
if (Object.keys(props).length) {
|
|
42
42
|
elements = elements.byProps(props);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webdriverio",
|
|
3
3
|
"description": "Next-gen WebDriver test automation framework for Node.js",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.9.2",
|
|
5
5
|
"homepage": "https://webdriver.io",
|
|
6
6
|
"author": "Christian Bromann <christian@saucelabs.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -55,19 +55,19 @@
|
|
|
55
55
|
"test:unit": "jest"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@wdio/config": "^5.
|
|
59
|
-
"@wdio/logger": "^5.
|
|
60
|
-
"@wdio/repl": "^5.
|
|
58
|
+
"@wdio/config": "^5.9.1",
|
|
59
|
+
"@wdio/logger": "^5.9.0",
|
|
60
|
+
"@wdio/repl": "^5.9.1",
|
|
61
61
|
"css-value": "^0.0.1",
|
|
62
62
|
"grapheme-splitter": "^1.0.2",
|
|
63
63
|
"lodash.isobject": "^3.0.2",
|
|
64
64
|
"lodash.isplainobject": "^4.0.6",
|
|
65
65
|
"lodash.merge": "^4.6.1",
|
|
66
66
|
"lodash.zip": "^4.2.0",
|
|
67
|
-
"resq": "^1.
|
|
67
|
+
"resq": "^1.5.0",
|
|
68
68
|
"rgb2hex": "^0.1.0",
|
|
69
69
|
"serialize-error": "^3.0.0",
|
|
70
|
-
"webdriver": "^5.
|
|
70
|
+
"webdriver": "^5.9.1"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "fc102df36cd2ab674aebf3eca1072d4866b0918b"
|
|
73
73
|
}
|
package/webdriverio-core.d.ts
CHANGED
|
@@ -203,6 +203,16 @@ declare namespace WebdriverIO {
|
|
|
203
203
|
xoffset?: number,
|
|
204
204
|
yoffset?: number
|
|
205
205
|
): void;
|
|
206
|
+
react$$(
|
|
207
|
+
selector: string,
|
|
208
|
+
props?: object,
|
|
209
|
+
state?: any[] | number | string | object | boolean
|
|
210
|
+
): Element[];
|
|
211
|
+
react$(
|
|
212
|
+
selector: string,
|
|
213
|
+
props?: object,
|
|
214
|
+
state?: any[] | number | string | object | boolean
|
|
215
|
+
): Element;
|
|
206
216
|
saveScreenshot(
|
|
207
217
|
filename: string
|
|
208
218
|
): Buffer;
|
|
@@ -267,12 +277,6 @@ declare namespace WebdriverIO {
|
|
|
267
277
|
executeAsync: ExecuteAsync;
|
|
268
278
|
call: Call;
|
|
269
279
|
options: Options;
|
|
270
|
-
waitUntil(
|
|
271
|
-
condition: () => boolean,
|
|
272
|
-
timeout?: number,
|
|
273
|
-
timeoutMsg?: string,
|
|
274
|
-
interval?: number
|
|
275
|
-
): boolean
|
|
276
280
|
$$(
|
|
277
281
|
selector: string | Function
|
|
278
282
|
): Element[];
|
|
@@ -299,14 +303,14 @@ declare namespace WebdriverIO {
|
|
|
299
303
|
milliseconds: number
|
|
300
304
|
): void;
|
|
301
305
|
react$$(
|
|
302
|
-
selector
|
|
306
|
+
selector: string,
|
|
303
307
|
props?: object,
|
|
304
|
-
state?: object
|
|
308
|
+
state?: any[] | number | string | object | boolean
|
|
305
309
|
): Element[];
|
|
306
310
|
react$(
|
|
307
|
-
selector
|
|
311
|
+
selector: string,
|
|
308
312
|
props?: object,
|
|
309
|
-
state?: object
|
|
313
|
+
state?: any[] | number | string | object | boolean
|
|
310
314
|
): Element;
|
|
311
315
|
reloadSession(): void;
|
|
312
316
|
saveRecordingScreen(
|
package/webdriverio.d.ts
CHANGED
|
@@ -45,7 +45,15 @@ declare namespace WebdriverIOAsync {
|
|
|
45
45
|
options: WebdriverIO.MultiRemoteOptions
|
|
46
46
|
): WebDriver.ClientAsync;
|
|
47
47
|
|
|
48
|
-
interface Browser extends BrowserAsync, BrowserStatic {
|
|
48
|
+
interface Browser extends BrowserAsync, BrowserStatic {
|
|
49
|
+
waitUntil(
|
|
50
|
+
condition: () => Promise<boolean>,
|
|
51
|
+
timeout?: number,
|
|
52
|
+
timeoutMsg?: string,
|
|
53
|
+
interval?: number
|
|
54
|
+
): Promise<boolean>
|
|
55
|
+
}
|
|
56
|
+
|
|
49
57
|
interface Element extends ElementAsync, ElementStatic { }
|
|
50
58
|
interface Config {}
|
|
51
59
|
}
|