webdriverio 5.11.11 → 5.11.12
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/$$.js +0 -42
- package/build/commands/browser/$.js +0 -42
- package/build/commands/browser/call.js +0 -38
- package/build/commands/browser/debug.js +1 -21
- package/build/commands/browser/deleteCookies.js +0 -43
- package/build/commands/browser/execute.js +0 -43
- package/build/commands/browser/executeAsync.js +0 -51
- package/build/commands/browser/getCookies.js +0 -32
- package/build/commands/browser/getWindowSize.js +0 -20
- package/build/commands/browser/keys.js +0 -36
- package/build/commands/browser/newWindow.js +0 -37
- package/build/commands/browser/pause.js +0 -21
- package/build/commands/browser/react$$.js +0 -24
- package/build/commands/browser/react$.js +0 -28
- package/build/commands/browser/reloadSession.js +1 -28
- package/build/commands/browser/saveRecordingScreen.js +0 -23
- package/build/commands/browser/saveScreenshot.js +0 -22
- package/build/commands/browser/setCookies.js +0 -46
- package/build/commands/browser/setTimeout.js +1 -38
- package/build/commands/browser/setWindowSize.js +0 -25
- package/build/commands/browser/switchWindow.js +0 -38
- package/build/commands/browser/touchAction.js +0 -60
- package/build/commands/browser/uploadFile.js +0 -32
- package/build/commands/browser/url.js +0 -33
- package/build/commands/browser/waitUntil.js +0 -40
- package/build/commands/constant.js +0 -18
- package/build/commands/element/$$.js +0 -39
- package/build/commands/element/$.js +0 -43
- package/build/commands/element/addValue.js +1 -28
- package/build/commands/element/clearValue.js +0 -26
- package/build/commands/element/click.js +0 -43
- package/build/commands/element/doubleClick.js +0 -30
- package/build/commands/element/dragAndDrop.js +1 -21
- package/build/commands/element/getAttribute.js +0 -26
- package/build/commands/element/getCSSProperty.js +0 -66
- package/build/commands/element/getHTML.js +1 -33
- package/build/commands/element/getLocation.js +0 -27
- package/build/commands/element/getProperty.js +0 -16
- package/build/commands/element/getSize.js +0 -27
- package/build/commands/element/getTagName.js +0 -23
- package/build/commands/element/getText.js +0 -40
- package/build/commands/element/getValue.js +0 -24
- package/build/commands/element/isDisplayed.js +1 -62
- package/build/commands/element/isDisplayedInViewport.js +1 -39
- package/build/commands/element/isEnabled.js +0 -32
- package/build/commands/element/isExisting.js +0 -40
- package/build/commands/element/isFocused.js +1 -29
- package/build/commands/element/isSelected.js +0 -29
- package/build/commands/element/moveTo.js +0 -21
- package/build/commands/element/react$$.js +0 -25
- package/build/commands/element/react$.js +0 -29
- package/build/commands/element/saveScreenshot.js +0 -21
- package/build/commands/element/scrollIntoView.js +2 -26
- package/build/commands/element/selectByAttribute.js +0 -46
- package/build/commands/element/selectByIndex.js +0 -40
- package/build/commands/element/selectByVisibleText.js +1 -43
- package/build/commands/element/setValue.js +0 -25
- package/build/commands/element/shadow$$.js +0 -18
- package/build/commands/element/shadow$.js +0 -18
- package/build/commands/element/touchAction.js +0 -53
- package/build/commands/element/waitForDisplayed.js +0 -37
- package/build/commands/element/waitForEnabled.js +0 -35
- package/build/commands/element/waitForExist.js +0 -38
- package/build/commands/element/waitUntil.js +0 -6
- package/build/constants.js +0 -128
- package/build/index.js +0 -25
- package/build/middlewares.js +0 -14
- package/build/multiremote.js +0 -46
- package/build/scripts/getHTML.js +0 -7
- package/build/scripts/getProperty.js +0 -6
- package/build/scripts/isDisplayedInViewport.js +0 -5
- package/build/scripts/isElementDisplayed.js +10 -71
- package/build/scripts/isFocused.js +0 -5
- package/build/scripts/newWindow.js +0 -8
- package/build/scripts/resq.js +2 -7
- package/build/scripts/shadowFnFactory.js +0 -1
- package/build/utils/Timer.js +4 -23
- package/build/utils/findStrategy.js +16 -48
- package/build/utils/getElementObject.js +0 -25
- package/build/utils/implicitWait.js +0 -12
- package/build/utils/refetchElement.js +2 -15
- package/build/utils.js +3 -119
- package/package.json +3 -3
- package/webdriverio-core.d.ts +0 -8
|
@@ -9,48 +9,6 @@ var _utils = require("../../utils");
|
|
|
9
9
|
|
|
10
10
|
var _getElementObject = require("../../utils/getElementObject");
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* The `$$` command is a short way to call the [`findElements`](/docs/api/webdriver.html#findelements) command in order
|
|
14
|
-
* to fetch multiple elements on the page. It returns an array with element results that will have an
|
|
15
|
-
* extended prototype to call action commands without passing in a selector. However if you still pass
|
|
16
|
-
* in a selector it will look for that element first and call the action on that element.
|
|
17
|
-
*
|
|
18
|
-
* Using the wdio testrunner this command is a global variable else it will be located on the browser object instead.
|
|
19
|
-
*
|
|
20
|
-
* You can chain `$` or `$$` together in order to walk down the DOM tree. For more information on how
|
|
21
|
-
* to select specific elements, see [`Selectors`](/docs/selectors.html).
|
|
22
|
-
*
|
|
23
|
-
* <example>
|
|
24
|
-
:index.html
|
|
25
|
-
<ul id="menu">
|
|
26
|
-
<li><a href="/">Home</a></li>
|
|
27
|
-
<li><a href="/">Developer Guide</a></li>
|
|
28
|
-
<li><a href="/">API</a></li>
|
|
29
|
-
<li><a href="/">Contribute</a></li>
|
|
30
|
-
</ul>
|
|
31
|
-
:$.js
|
|
32
|
-
it('should get text a menu link', () => {
|
|
33
|
-
const text = $$('#menu')[0];
|
|
34
|
-
console.log(text.$$('li')[2].$('a').getText()); // outputs: "API"
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should get text a menu link - JS Function', () => {
|
|
38
|
-
const text = $$(function() { // Arrow function is not allowed here.
|
|
39
|
-
// this is Window https://developer.mozilla.org/en-US/docs/Web/API/Window
|
|
40
|
-
// TypeScript users may do something like this
|
|
41
|
-
// return (this as Window).document.querySelectorAll('#menu')
|
|
42
|
-
return this.document.querySelectorAll('#menu'); // Element[]
|
|
43
|
-
})[0];
|
|
44
|
-
console.log(text.$$('li')[2].$('a').getText()); // outputs: "API"
|
|
45
|
-
});
|
|
46
|
-
* </example>
|
|
47
|
-
*
|
|
48
|
-
* @alias $$
|
|
49
|
-
* @param {String|Function} selector selector or JS Function to fetch multiple elements
|
|
50
|
-
* @return {Element[]}
|
|
51
|
-
* @type utility
|
|
52
|
-
*
|
|
53
|
-
*/
|
|
54
12
|
async function $$(selector) {
|
|
55
13
|
const res = await _utils.findElements.call(this, selector);
|
|
56
14
|
return _getElementObject.getElements.call(this, selector, res);
|
|
@@ -9,48 +9,6 @@ var _utils = require("../../utils");
|
|
|
9
9
|
|
|
10
10
|
var _getElementObject = require("../../utils/getElementObject");
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* The `$` command is a short way to call the [`findElement`](/docs/api/webdriver.html#findelement) command in order
|
|
14
|
-
* to fetch a single element on the page. It returns an object that with an extended prototype to call
|
|
15
|
-
* action commands without passing in a selector. However if you still pass in a selector it will look
|
|
16
|
-
* for that element first and call the action on that element.
|
|
17
|
-
*
|
|
18
|
-
* Using the wdio testrunner this command is a global variable else it will be located on the browser object instead.
|
|
19
|
-
*
|
|
20
|
-
* You can chain `$` or `$$` together in order to walk down the DOM tree. For more information on how
|
|
21
|
-
* to select specific elements, see [`Selectors`](/docs/selectors.html).
|
|
22
|
-
*
|
|
23
|
-
* <example>
|
|
24
|
-
:index.html
|
|
25
|
-
<ul id="menu">
|
|
26
|
-
<li><a href="/">Home</a></li>
|
|
27
|
-
<li><a href="/">Developer Guide</a></li>
|
|
28
|
-
<li><a href="/">API</a></li>
|
|
29
|
-
<li><a href="/">Contribute</a></li>
|
|
30
|
-
</ul>
|
|
31
|
-
:$.js
|
|
32
|
-
it('should get text a menu link', () => {
|
|
33
|
-
const text = $('#menu');
|
|
34
|
-
console.log(text.$$('li')[2].$('a').getText()); // outputs: "API"
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should get text a menu link - JS Function', () => {
|
|
38
|
-
const text = $(function() { // Arrow function is not allowed here.
|
|
39
|
-
// this is Window https://developer.mozilla.org/en-US/docs/Web/API/Window
|
|
40
|
-
// TypeScript users may do something like this
|
|
41
|
-
// return (this as Window).document.querySelector('#menu')
|
|
42
|
-
return this.document.querySelector('#menu'); // Element
|
|
43
|
-
});
|
|
44
|
-
console.log(text.$$('li')[2].$('a').getText()); // outputs: "API"
|
|
45
|
-
});
|
|
46
|
-
* </example>
|
|
47
|
-
*
|
|
48
|
-
* @alias $
|
|
49
|
-
* @param {String|Function} selector selector or JS Function to fetch a certain element
|
|
50
|
-
* @return {Element}
|
|
51
|
-
* @type utility
|
|
52
|
-
*
|
|
53
|
-
*/
|
|
54
12
|
async function $(selector) {
|
|
55
13
|
const res = await _utils.findElement.call(this, selector);
|
|
56
14
|
return _getElementObject.getElement.call(this, selector, res);
|
|
@@ -5,44 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = call;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* You can use `call` to execute any async action within your test spec. The command itself
|
|
10
|
-
* is treated like a synchronous function. It accepts promises and stops the execution until
|
|
11
|
-
* the promise has resolved.
|
|
12
|
-
*
|
|
13
|
-
* <example>
|
|
14
|
-
:call.js
|
|
15
|
-
it('some testing here', () => {
|
|
16
|
-
browser.url('http://google.com')
|
|
17
|
-
// make an asynchronous call using any 3rd party library supporting promises
|
|
18
|
-
// e.g. call to backend or db to inject fixture data
|
|
19
|
-
browser.call(() => {
|
|
20
|
-
return somePromiseLibrary.someMethod().then(() => {
|
|
21
|
-
// ...
|
|
22
|
-
})
|
|
23
|
-
})
|
|
24
|
-
// example for async call to 3rd party library that doesn't support promises
|
|
25
|
-
browser.call(() => {
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
someOtherNodeLibrary.someMethod(param1, (err, res) => {
|
|
28
|
-
if (err) {
|
|
29
|
-
return reject(err)
|
|
30
|
-
}
|
|
31
|
-
resolve(res)
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
// continue synchronously
|
|
36
|
-
$('#elemA').click()
|
|
37
|
-
$('.firstname').setValue('webdriverbot')
|
|
38
|
-
});
|
|
39
|
-
* </example>
|
|
40
|
-
*
|
|
41
|
-
* @alias browser.call
|
|
42
|
-
* @param {Function} callback function to be called
|
|
43
|
-
* @type utility
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
8
|
function call(fn = () => {}) {
|
|
47
9
|
return fn();
|
|
48
10
|
}
|
|
@@ -22,12 +22,8 @@ function debug(commandTimeout = 5000) {
|
|
|
22
22
|
const {
|
|
23
23
|
introMessage
|
|
24
24
|
} = _repl.default;
|
|
25
|
-
/**
|
|
26
|
-
* run repl in standalone mode
|
|
27
|
-
*/
|
|
28
25
|
|
|
29
26
|
if (!process.env.WDIO_WORKER) {
|
|
30
|
-
// eslint-disable-next-line
|
|
31
27
|
console.log(_repl.default.introMessage);
|
|
32
28
|
const context = {
|
|
33
29
|
browser: this,
|
|
@@ -37,16 +33,8 @@ function debug(commandTimeout = 5000) {
|
|
|
37
33
|
};
|
|
38
34
|
return repl.start(context);
|
|
39
35
|
}
|
|
40
|
-
/**
|
|
41
|
-
* register worker process as debugger target
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
36
|
|
|
45
37
|
process._debugProcess(process.pid);
|
|
46
|
-
/**
|
|
47
|
-
* initialise repl in testrunner
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
38
|
|
|
51
39
|
process.send({
|
|
52
40
|
origin: 'debugger',
|
|
@@ -57,9 +45,7 @@ function debug(commandTimeout = 5000) {
|
|
|
57
45
|
}
|
|
58
46
|
});
|
|
59
47
|
|
|
60
|
-
let commandResolve =
|
|
61
|
-
/* istanbul ignore next */
|
|
62
|
-
() => {};
|
|
48
|
+
let commandResolve = () => {};
|
|
63
49
|
|
|
64
50
|
process.on('message', m => {
|
|
65
51
|
if (m.origin !== 'debugger') {
|
|
@@ -71,8 +57,6 @@ function debug(commandTimeout = 5000) {
|
|
|
71
57
|
|
|
72
58
|
return commandResolve();
|
|
73
59
|
}
|
|
74
|
-
/* istanbul ignore if */
|
|
75
|
-
|
|
76
60
|
|
|
77
61
|
if (m.name === 'eval') {
|
|
78
62
|
repl.eval(m.content.cmd, global, null, (e, result) => {
|
|
@@ -85,10 +69,6 @@ function debug(commandTimeout = 5000) {
|
|
|
85
69
|
}, (0, _serializeError.default)(e))
|
|
86
70
|
});
|
|
87
71
|
}
|
|
88
|
-
/**
|
|
89
|
-
* try to do some smart serializations
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
72
|
|
|
93
73
|
if (typeof result === 'function') {
|
|
94
74
|
result = `[Function: ${result.name}]`;
|
|
@@ -5,49 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = deleteCookies;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Delete cookies visible to the current page. By providing a cookie name it just removes the single cookie or more when multiple names are passed.
|
|
11
|
-
*
|
|
12
|
-
* <example>
|
|
13
|
-
:deleteCookie.js
|
|
14
|
-
it('should delete cookies', () => {
|
|
15
|
-
browser.setCookies([
|
|
16
|
-
{name: 'test', value: '123'},
|
|
17
|
-
{name: 'test2', value: '456'},
|
|
18
|
-
{name: 'test3', value: '789'}
|
|
19
|
-
])
|
|
20
|
-
|
|
21
|
-
let cookies = browser.getCookies()
|
|
22
|
-
console.log(cookies)
|
|
23
|
-
// outputs:
|
|
24
|
-
// [
|
|
25
|
-
// { name: 'test', value: '123' },
|
|
26
|
-
// { name: 'test2', value: '456' }
|
|
27
|
-
// { name: 'test3', value: '789' }
|
|
28
|
-
// ]
|
|
29
|
-
|
|
30
|
-
browser.deleteCookies(['test3'])
|
|
31
|
-
cookies = browser.getCookies()
|
|
32
|
-
console.log(cookies)
|
|
33
|
-
// outputs:
|
|
34
|
-
// [
|
|
35
|
-
// { name: 'test', value: '123' },
|
|
36
|
-
// { name: 'test2', value: '456' }
|
|
37
|
-
// ]
|
|
38
|
-
|
|
39
|
-
browser.deleteCookies()
|
|
40
|
-
cookies = browser.getCookies()
|
|
41
|
-
console.log(cookies) // outputs: []
|
|
42
|
-
})
|
|
43
|
-
* </example>
|
|
44
|
-
*
|
|
45
|
-
* @alias browser.deleteCookies
|
|
46
|
-
* @param {String[]=} names names of cookies to be deleted
|
|
47
|
-
* @uses webdriver/deleteAllCookies,webdriver/deleteCookie
|
|
48
|
-
* @type cookie
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
8
|
function deleteCookies(names) {
|
|
52
9
|
const namesList = typeof names !== 'undefined' && !Array.isArray(names) ? [names] : names;
|
|
53
10
|
|
|
@@ -7,55 +7,12 @@ exports.default = execute;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame.
|
|
13
|
-
* The executed script is assumed to be synchronous and the result of evaluating the script is returned to
|
|
14
|
-
* the client.
|
|
15
|
-
*
|
|
16
|
-
* The script argument defines the script to execute in the form of a function body. The value returned by
|
|
17
|
-
* that function will be returned to the client. The function will be invoked with the provided args array
|
|
18
|
-
* and the values may be accessed via the arguments object in the order specified.
|
|
19
|
-
*
|
|
20
|
-
* Arguments may be any JSON-primitive, array, or JSON object. JSON objects that define a WebElement
|
|
21
|
-
* reference will be converted to the corresponding DOM element. Likewise, any WebElements in the script
|
|
22
|
-
* result will be returned to the client as WebElement JSON objects.
|
|
23
|
-
*
|
|
24
|
-
* <example>
|
|
25
|
-
:execute.js
|
|
26
|
-
it('should inject javascript on the page', () => {
|
|
27
|
-
const result = browser.execute((a, b, c, d) => {
|
|
28
|
-
// browser context - you may not access client or console
|
|
29
|
-
return a + b + c + d
|
|
30
|
-
}, 1, 2, 3, 4)
|
|
31
|
-
// node.js context - client and console are available
|
|
32
|
-
console.log(result) // outputs: 10
|
|
33
|
-
});
|
|
34
|
-
* </example>
|
|
35
|
-
*
|
|
36
|
-
* @param {String|Function} script The script to execute.
|
|
37
|
-
* @param {*=} arguments script arguments
|
|
38
|
-
*
|
|
39
|
-
* @return {*} The script result.
|
|
40
|
-
*
|
|
41
|
-
* @see https://w3c.github.io/webdriver/webdriver-spec.html#dfn-execute-script
|
|
42
|
-
* @type protocol
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
10
|
function execute(...args) {
|
|
46
11
|
let script = args.shift();
|
|
47
|
-
/*!
|
|
48
|
-
* parameter check
|
|
49
|
-
*/
|
|
50
12
|
|
|
51
13
|
if (typeof script !== 'string' && typeof script !== 'function') {
|
|
52
14
|
throw new Error('number or type of arguments don\'t agree with execute protocol command');
|
|
53
15
|
}
|
|
54
|
-
/*!
|
|
55
|
-
* instances started as multibrowserinstance can't getting called with
|
|
56
|
-
* a function parameter, therefor we need to check if it starts with "function () {"
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
16
|
|
|
60
17
|
if (typeof script === 'function') {
|
|
61
18
|
script = `return (${script}).apply(null, arguments)`;
|
|
@@ -7,63 +7,12 @@ exports.default = executeAsync;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Inject a snippet of JavaScript into the page for execution in the context of the currently selected
|
|
13
|
-
* frame. The executed script is assumed to be asynchronous and must signal that is done by invoking
|
|
14
|
-
* the provided callback, which is always provided as the final argument to the function. The value
|
|
15
|
-
* to this callback will be returned to the client.
|
|
16
|
-
*
|
|
17
|
-
* Asynchronous script commands may not span page loads. If an unload event is fired while waiting
|
|
18
|
-
* for a script result, an error should be returned to the client.
|
|
19
|
-
*
|
|
20
|
-
* The script argument defines the script to execute in the form of a function body. The function will
|
|
21
|
-
* be invoked with the provided args array and the values may be accessed via the arguments object
|
|
22
|
-
* in the order specified. The final argument will always be a callback function that must be invoked
|
|
23
|
-
* to signal that the script has finished.
|
|
24
|
-
*
|
|
25
|
-
* Arguments may be any JSON-primitive, array, or JSON object. JSON objects that define a WebElement
|
|
26
|
-
* reference will be converted to the corresponding DOM element. Likewise, any WebElements in the script
|
|
27
|
-
* result will be returned to the client as WebElement JSON objects.
|
|
28
|
-
*
|
|
29
|
-
* <example>
|
|
30
|
-
:executeAsync.js
|
|
31
|
-
it('should execute async JavaScript on the page', () => {
|
|
32
|
-
browser.setTimeout({ script: 5000 })
|
|
33
|
-
const result = browser.executeAsync(function(a, b, c, d, done) {
|
|
34
|
-
// browser context - you may not access client or console
|
|
35
|
-
setTimeout(() => {
|
|
36
|
-
done(a + b + c + d)
|
|
37
|
-
}, 3000);
|
|
38
|
-
}, 1, 2, 3, 4)
|
|
39
|
-
// node.js context - client and console are available
|
|
40
|
-
console.log(result) // outputs: 10
|
|
41
|
-
});
|
|
42
|
-
* </example>
|
|
43
|
-
*
|
|
44
|
-
* @param {String|Function} script The script to execute.
|
|
45
|
-
* @param {*=} arguments script arguments
|
|
46
|
-
*
|
|
47
|
-
* @return {*} The script result.
|
|
48
|
-
*
|
|
49
|
-
* @see https://w3c.github.io/webdriver/webdriver-spec.html#dfn-execute-async-script
|
|
50
|
-
* @type protocol
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
10
|
function executeAsync(...args) {
|
|
54
11
|
let script = args.shift();
|
|
55
|
-
/*!
|
|
56
|
-
* parameter check
|
|
57
|
-
*/
|
|
58
12
|
|
|
59
13
|
if (typeof script !== 'string' && typeof script !== 'function') {
|
|
60
14
|
throw new Error('number or type of arguments don\'t agree with execute protocol command');
|
|
61
15
|
}
|
|
62
|
-
/*!
|
|
63
|
-
* instances started as multibrowserinstance can't getting called with
|
|
64
|
-
* a function parameter, therefor we need to check if it starts with "function () {"
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
16
|
|
|
68
17
|
if (typeof script === 'function') {
|
|
69
18
|
script = `return (${script}).apply(null, arguments)`;
|
|
@@ -5,38 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getCookies;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Retrieve a [cookie](https://w3c.github.io/webdriver/webdriver-spec.html#cookies)
|
|
11
|
-
* visible to the current page. You can query a specific cookie by providing the cookie name or
|
|
12
|
-
* retrieve all.
|
|
13
|
-
*
|
|
14
|
-
* <example>
|
|
15
|
-
:getCookies.js
|
|
16
|
-
it('should return a cookie for me', () => {
|
|
17
|
-
browser.setCookies([
|
|
18
|
-
{name: 'test', value: '123'},
|
|
19
|
-
{name: 'test2', value: '456'}
|
|
20
|
-
])
|
|
21
|
-
const testCookie = browser.getCookies(['test'])
|
|
22
|
-
console.log(testCookie); // outputs: [{ name: 'test', value: '123' }]
|
|
23
|
-
|
|
24
|
-
const allCookies = browser.getCookies()
|
|
25
|
-
console.log(allCookies);
|
|
26
|
-
// outputs:
|
|
27
|
-
// [
|
|
28
|
-
// { name: 'test', value: '123' },
|
|
29
|
-
// { name: 'test2', value: '456' }
|
|
30
|
-
// ]
|
|
31
|
-
})
|
|
32
|
-
* </example>
|
|
33
|
-
*
|
|
34
|
-
* @alias browser.getCookies
|
|
35
|
-
* @param {String[]=} names names of requested cookies
|
|
36
|
-
* @return {Object[]} requested cookies if existing
|
|
37
|
-
* @uses webdriver/getAllCookies
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
8
|
async function getCookies(names) {
|
|
41
9
|
const namesList = typeof names !== 'undefined' && !Array.isArray(names) ? [names] : names;
|
|
42
10
|
|
|
@@ -7,26 +7,6 @@ exports.default = getWindowSize;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Returns browser window size (and position for drivers with W3C support).
|
|
13
|
-
*
|
|
14
|
-
* <example>
|
|
15
|
-
* :getWindowSize.js
|
|
16
|
-
it('should return browser window size', function () {
|
|
17
|
-
const windowSize = browser.getWindowSize(500, 600);
|
|
18
|
-
console.log(windowSize);
|
|
19
|
-
// outputs
|
|
20
|
-
// Firefox: { x: 4, y: 23, width: 1280, height: 767 }
|
|
21
|
-
// Chrome: { width: 1280, height: 767 }
|
|
22
|
-
});
|
|
23
|
-
* </example>
|
|
24
|
-
*
|
|
25
|
-
* @alias browser.getWindowSize
|
|
26
|
-
* @return {Object} { x, y, width, height } for W3C or { width, height } for non W3C browser
|
|
27
|
-
* @type window
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
10
|
function getWindowSize() {
|
|
31
11
|
const browser = (0, _utils.getBrowserObject)(this);
|
|
32
12
|
|
|
@@ -7,36 +7,8 @@ exports.default = keys;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Send a sequence of key strokes to the active element. You can also use characters like
|
|
13
|
-
* "Left arrow" or "Back space". WebdriverIO will take care of translating them into unicode
|
|
14
|
-
* characters. You’ll find all supported characters [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
|
|
15
|
-
* To do that, the value has to correspond to a key from the table.
|
|
16
|
-
*
|
|
17
|
-
* Modifier like Ctrl, Shift, Alt and Meta will stay pressed so you need to trigger them again to release them.
|
|
18
|
-
*
|
|
19
|
-
* <example>
|
|
20
|
-
:keys.js
|
|
21
|
-
it('copies text out of active element', () => {
|
|
22
|
-
// copies text from an input element
|
|
23
|
-
const input = $('#username')
|
|
24
|
-
input.setValue('anonymous')
|
|
25
|
-
|
|
26
|
-
browser.keys(['Meta', 'a'])
|
|
27
|
-
browser.keys(['Meta', 'c'])
|
|
28
|
-
});
|
|
29
|
-
* </example>
|
|
30
|
-
*
|
|
31
|
-
* @param {String|String[]} value The sequence of keys to type. An array or string must be provided.
|
|
32
|
-
* @see https://w3c.github.io/webdriver/#dispatching-actions
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
10
|
function keys(value) {
|
|
36
11
|
let keySequence = [];
|
|
37
|
-
/**
|
|
38
|
-
* replace key with corresponding unicode character
|
|
39
|
-
*/
|
|
40
12
|
|
|
41
13
|
if (typeof value === 'string') {
|
|
42
14
|
keySequence = (0, _utils.checkUnicode)(value);
|
|
@@ -47,18 +19,10 @@ function keys(value) {
|
|
|
47
19
|
} else {
|
|
48
20
|
throw new Error('"keys" command requires a string or array of strings as parameter');
|
|
49
21
|
}
|
|
50
|
-
/**
|
|
51
|
-
* JsonWireProtocol action
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
22
|
|
|
55
23
|
if (!this.isW3C) {
|
|
56
24
|
return this.sendKeys(keySequence);
|
|
57
25
|
}
|
|
58
|
-
/**
|
|
59
|
-
* W3C way of handle it key actions
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
26
|
|
|
63
27
|
const keyDownActions = keySequence.map(value => ({
|
|
64
28
|
type: 'keyDown',
|
|
@@ -9,47 +9,10 @@ var _newWindow = _interopRequireDefault(require("../../scripts/newWindow"));
|
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* Open new window in browser. This command is the equivalent function to `window.open()`. This command does not
|
|
15
|
-
* work in mobile environments.
|
|
16
|
-
*
|
|
17
|
-
* __Note:__ When calling this command you automatically switch to the new window.
|
|
18
|
-
*
|
|
19
|
-
* <example>
|
|
20
|
-
:newWindowSync.js
|
|
21
|
-
it('should open a new tab', () => {
|
|
22
|
-
browser.url('http://google.com')
|
|
23
|
-
console.log(browser.getTitle()) // outputs: "Google"
|
|
24
|
-
|
|
25
|
-
browser.newWindow('https://webdriver.io', 'WebdriverIO window', 'width=420,height=230,resizable,scrollbars=yes,status=1')
|
|
26
|
-
console.log(browser.getTitle()) // outputs: "WebdriverIO · Next-gen WebDriver test framework for Node.js"
|
|
27
|
-
|
|
28
|
-
browser.closeWindow()
|
|
29
|
-
console.log(browser.getTitle()) // outputs: "Google"
|
|
30
|
-
});
|
|
31
|
-
* </example>
|
|
32
|
-
*
|
|
33
|
-
* @param {String} url website URL to open
|
|
34
|
-
* @param {String=} windowName name of the new window
|
|
35
|
-
* @param {String=} windowFeatures features of opened window (e.g. size, position, scrollbars, etc.)
|
|
36
|
-
* @return {String} id of window handle of new tab
|
|
37
|
-
*
|
|
38
|
-
* @uses browser/execute, protocol/getWindowHandles, protocol/switchToWindow
|
|
39
|
-
* @alias browser.newWindow
|
|
40
|
-
* @type window
|
|
41
|
-
*/
|
|
42
12
|
async function newWindow(url, windowName = 'New Window', windowFeatures = '') {
|
|
43
|
-
/*!
|
|
44
|
-
* parameter check
|
|
45
|
-
*/
|
|
46
13
|
if (typeof url !== 'string') {
|
|
47
14
|
throw new Error('number or type of arguments don\'t agree with newWindow command');
|
|
48
15
|
}
|
|
49
|
-
/*!
|
|
50
|
-
* mobile check
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
16
|
|
|
54
17
|
if (this.isMobile) {
|
|
55
18
|
throw new Error('newWindow command is not supported on mobile platforms');
|
|
@@ -5,27 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = pause;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Pauses execution for a specific amount of time. It is recommended to not use this command to wait for an
|
|
11
|
-
* element to show up. In order to avoid flaky test results it is better to use commands like
|
|
12
|
-
* [`waitforExist`](/docs/api/element/waitForExist.html) or other waitFor* commands.
|
|
13
|
-
*
|
|
14
|
-
* <example>
|
|
15
|
-
:pause.js
|
|
16
|
-
it('should pause the execution', () => {
|
|
17
|
-
const starttime = new Date().getTime()
|
|
18
|
-
browser.pause(3000)
|
|
19
|
-
const endtime = new Date().getTime()
|
|
20
|
-
console.log(endtime - starttime) // outputs: 3000
|
|
21
|
-
});
|
|
22
|
-
* </example>
|
|
23
|
-
*
|
|
24
|
-
* @alias browser.pause
|
|
25
|
-
* @param {Number} milliseconds time in ms
|
|
26
|
-
* @type utility
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
8
|
function pause(milliseconds = 1000) {
|
|
30
9
|
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
31
10
|
}
|
|
@@ -13,30 +13,6 @@ var _resq = require("../../scripts/resq");
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
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
|
-
|
|
28
|
-
const orangeButtons = browser.react$$('t', { orange: true })
|
|
29
|
-
console.log(orangeButtons.map((btn) => btn.getText())); // prints "[ '÷', 'x', '-', '+', '=' ]"
|
|
30
|
-
});
|
|
31
|
-
* </example>
|
|
32
|
-
*
|
|
33
|
-
* @alias browser.react$$
|
|
34
|
-
* @param {String} selector of React component
|
|
35
|
-
* @param {Object=} props React props the element should contain
|
|
36
|
-
* @param {Array<any>|number|string|object|boolean=} state React state the element should be in
|
|
37
|
-
* @return {Element[]}
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
16
|
const resqScript = _fs.default.readFileSync(require.resolve('resq'));
|
|
41
17
|
|
|
42
18
|
async function react$$(selector, props = {}, state = {}) {
|
|
@@ -13,34 +13,6 @@ var _resq = require("../../scripts/resq");
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
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
|
-
|
|
28
|
-
browser.react$('t', { name: '7' }).click()
|
|
29
|
-
browser.react$('t', { name: 'x' }).click()
|
|
30
|
-
browser.react$('t', { name: '6' }).click()
|
|
31
|
-
browser.react$('t', { name: '=' }).click()
|
|
32
|
-
|
|
33
|
-
console.log($('.component-display').getText()); // prints "42"
|
|
34
|
-
});
|
|
35
|
-
* </example>
|
|
36
|
-
*
|
|
37
|
-
* @alias browser.react$
|
|
38
|
-
* @param {String} selector of React component
|
|
39
|
-
* @param {Object=} props React props the element should contain
|
|
40
|
-
* @param {Array<any>|number|string|object|boolean=} state React state the element should be in
|
|
41
|
-
* @return {Element}
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
16
|
const resqScript = _fs.default.readFileSync(require.resolve('resq'));
|
|
45
17
|
|
|
46
18
|
async function react$(selector, props = {}, state = {}) {
|