webdriverio 5.11.6 → 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 +4 -22
- 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 +1 -27
- package/build/commands/browser/saveScreenshot.js +1 -26
- 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/browser.js +106 -0
- 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 +1 -25
- 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/commands/element.js +158 -0
- package/build/constants.js +0 -128
- package/build/index.js +0 -25
- package/build/middlewares.js +2 -16
- package/build/multiremote.js +9 -48
- 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 +13 -31
- package/build/utils/implicitWait.js +0 -12
- package/build/utils/refetchElement.js +13 -19
- package/build/utils.js +14 -128
- package/package.json +4 -5
- package/webdriverio-core.d.ts +0 -8
|
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.touchAction = exports.validateParameters = exports.formatArgs = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Constants around commands
|
|
10
|
-
*/
|
|
11
7
|
const TOUCH_ACTIONS = ['press', 'longPress', 'tap', 'moveTo', 'wait', 'release'];
|
|
12
8
|
const POS_ACTIONS = TOUCH_ACTIONS.slice(0, 4);
|
|
13
9
|
const ACCEPTED_OPTIONS = ['x', 'y', 'element'];
|
|
@@ -27,10 +23,6 @@ const formatArgs = function (scope, actions) {
|
|
|
27
23
|
const formattedAction = {
|
|
28
24
|
action: action.action,
|
|
29
25
|
options: {}
|
|
30
|
-
/**
|
|
31
|
-
* don't propagate for actions that don't require element options
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
26
|
};
|
|
35
27
|
const actionElement = action.element && typeof action.element.elementId === 'string' ? action.element.elementId : scope.elementId;
|
|
36
28
|
|
|
@@ -41,9 +33,6 @@ const formatArgs = function (scope, actions) {
|
|
|
41
33
|
if (isFinite(action.x)) formattedAction.options.x = action.x;
|
|
42
34
|
if (isFinite(action.y)) formattedAction.options.y = action.y;
|
|
43
35
|
if (action.ms) formattedAction.options.ms = action.ms;
|
|
44
|
-
/**
|
|
45
|
-
* remove options property if empty
|
|
46
|
-
*/
|
|
47
36
|
|
|
48
37
|
if (Object.keys(formattedAction.options).length === 0) {
|
|
49
38
|
delete formattedAction.options;
|
|
@@ -52,13 +41,6 @@ const formatArgs = function (scope, actions) {
|
|
|
52
41
|
return formattedAction;
|
|
53
42
|
});
|
|
54
43
|
};
|
|
55
|
-
/**
|
|
56
|
-
* Make sure action has proper options before sending command to Appium.
|
|
57
|
-
*
|
|
58
|
-
* @param {Object} params touchAction parameters
|
|
59
|
-
* @return null
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
44
|
|
|
63
45
|
exports.formatArgs = formatArgs;
|
|
64
46
|
|
|
@@ -9,45 +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 similar to the `$$` command from the browser scope. The difference when calling
|
|
15
|
-
* it from an element scope is that the driver will look within the children of that element.
|
|
16
|
-
*
|
|
17
|
-
* For more information on how to select specific elements, see [`Selectors`](/docs/selectors.html).
|
|
18
|
-
*
|
|
19
|
-
* <example>
|
|
20
|
-
:index.html
|
|
21
|
-
<ul id="menu">
|
|
22
|
-
<li><a href="/">Home</a></li>
|
|
23
|
-
<li><a href="/">Developer Guide</a></li>
|
|
24
|
-
<li><a href="/">API</a></li>
|
|
25
|
-
<li><a href="/">Contribute</a></li>
|
|
26
|
-
</ul>
|
|
27
|
-
:$.js
|
|
28
|
-
it('should get text a menu link', () => {
|
|
29
|
-
const text = $('#menu');
|
|
30
|
-
console.log(text.$$('li')[2].$('a').getText()); // outputs: "API"
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should get text a menu link - JS Function', () => {
|
|
34
|
-
const text = $('#menu');
|
|
35
|
-
console.log(text.$$(function() { // Arrow function is not allowed here.
|
|
36
|
-
// this is Element https://developer.mozilla.org/en-US/docs/Web/API/Element
|
|
37
|
-
// in this particular example it is HTMLUListElement
|
|
38
|
-
// TypeScript users may do something like this
|
|
39
|
-
// return (this as Element).querySelectorAll('li')
|
|
40
|
-
return this.querySelectorAll('li'); // Element[]
|
|
41
|
-
})[2].$('a').getText()); // outputs: "API"
|
|
42
|
-
});
|
|
43
|
-
* </example>
|
|
44
|
-
*
|
|
45
|
-
* @alias $$
|
|
46
|
-
* @param {String|Function} selector selector or JS Function to fetch multiple elements
|
|
47
|
-
* @return {Element[]}
|
|
48
|
-
* @type utility
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
12
|
async function $$(selector) {
|
|
52
13
|
const res = await _utils.findElements.call(this, selector);
|
|
53
14
|
return _getElementObject.getElements.call(this, selector, res);
|
|
@@ -9,49 +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 similar to the `$` command from the browser scope. The difference when calling
|
|
15
|
-
* it from an element scope is that the driver will look within the children of that element.
|
|
16
|
-
*
|
|
17
|
-
* Note: chaining `$` and `$$` commands only make sense when you use multiple selector strategies. You will otherwise
|
|
18
|
-
* make unnecessary requests that slow down the test (e.g. `$('body').$('div')` will trigger two request whereas
|
|
19
|
-
* `$('body div')` does literary the same with just one request)
|
|
20
|
-
*
|
|
21
|
-
* For more information on how 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 = $('#menu');
|
|
39
|
-
console.log(text.$$('li')[2].$(function() { // Arrow function is not allowed here.
|
|
40
|
-
// this is Element https://developer.mozilla.org/en-US/docs/Web/API/Element
|
|
41
|
-
// in this particular example it is HTMLLIElement
|
|
42
|
-
// TypeScript users may do something like this
|
|
43
|
-
// return (this as Element).querySelector('a')
|
|
44
|
-
return this.querySelector('a'); // Element
|
|
45
|
-
}).getText()); // outputs: "API"
|
|
46
|
-
});
|
|
47
|
-
* </example>
|
|
48
|
-
*
|
|
49
|
-
* @alias $
|
|
50
|
-
* @param {String|Function} selector selector or JS Function to fetch a certain element
|
|
51
|
-
* @return {Element}
|
|
52
|
-
* @type utility
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
12
|
async function $(selector) {
|
|
56
13
|
const res = await _utils.findElement.call(this, selector);
|
|
57
14
|
return _getElementObject.getElement.call(this, selector, res);
|
|
@@ -7,37 +7,10 @@ exports.default = addValue;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Add a value to an object found by given selector. You can also use unicode
|
|
13
|
-
* characters like Left arrow or Back space. WebdriverIO will take care of
|
|
14
|
-
* translating them into unicode characters. You’ll find all supported characters
|
|
15
|
-
* [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
|
|
16
|
-
* To do that, the value has to correspond to a key from the table.
|
|
17
|
-
*
|
|
18
|
-
* <example>
|
|
19
|
-
:addValue.js
|
|
20
|
-
it('should demonstrate the addValue command', () => {
|
|
21
|
-
let input = $('.input')
|
|
22
|
-
input.addValue('test')
|
|
23
|
-
input.addValue(123)
|
|
24
|
-
|
|
25
|
-
value = input.getValue()
|
|
26
|
-
assert(value === 'test123') // true
|
|
27
|
-
})
|
|
28
|
-
* </example>
|
|
29
|
-
*
|
|
30
|
-
* @alias element.addValue
|
|
31
|
-
* @param {string | number | boolean | object | Array<any>} value value to be added
|
|
32
|
-
* @uses protocol/elements, protocol/elementIdValue
|
|
33
|
-
* @type action
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
10
|
function addValue(value) {
|
|
37
11
|
if (!this.isW3C) {
|
|
38
12
|
return this.elementSendKeys(this.elementId, (0, _utils.transformToCharString)(value));
|
|
39
|
-
}
|
|
40
|
-
|
|
13
|
+
}
|
|
41
14
|
|
|
42
15
|
if (this.isMobile) {
|
|
43
16
|
return this.elementSendKeys(this.elementId, (0, _utils.transformToCharString)(value).join(''), (0, _utils.transformToCharString)(value));
|
|
@@ -5,32 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = clearValue;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Clear a `<textarea>` or text `<input>` element’s value. Make sure you can interact with the
|
|
11
|
-
* element before using this command. You can't clear an input element that is disabled or in
|
|
12
|
-
* readonly mode.
|
|
13
|
-
*
|
|
14
|
-
* <example>
|
|
15
|
-
:clearValue.js
|
|
16
|
-
it('should demonstrate the clearValue command', function () {
|
|
17
|
-
const elem = $('.input')
|
|
18
|
-
elem.setValue('test123')
|
|
19
|
-
|
|
20
|
-
const value = elem.getValue()
|
|
21
|
-
console.log(value) // returns 'test123'
|
|
22
|
-
|
|
23
|
-
elem.clearValue()
|
|
24
|
-
value = elem.getValue()
|
|
25
|
-
assert(value === ''); // true
|
|
26
|
-
})
|
|
27
|
-
* </example>
|
|
28
|
-
*
|
|
29
|
-
* @alias element.clearValue
|
|
30
|
-
* @uses protocol/elements, protocol/elementIdClear
|
|
31
|
-
* @type action
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
8
|
function clearValue() {
|
|
35
9
|
return this.elementClear(this.elementId);
|
|
36
10
|
}
|
|
@@ -5,49 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = click;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Click on an element.
|
|
11
|
-
*
|
|
12
|
-
* Note: This issues a Webdriver `click` command for the selected element, which generally scrolls to and then clicks the
|
|
13
|
-
* selected element. However, if you have fixed-position elements (such as a fixed header or footer) that cover up the
|
|
14
|
-
* selected element after it is scrolled within the viewport, the click will be issued at the given coordinates, but will
|
|
15
|
-
* be received by your fixed (overlaying) element. In these cased the following error is thrown:
|
|
16
|
-
*
|
|
17
|
-
* ```
|
|
18
|
-
* Element is not clickable at point (x, x). Other element would receive the click: ..."
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* To work around this, try to find the overlaying element and remove it via `execute` command so it doesn't interfere
|
|
22
|
-
* the click. You also can try to scroll to the element yourself using `scroll` with an offset appropriate for your
|
|
23
|
-
* scenario.
|
|
24
|
-
*
|
|
25
|
-
* <example>
|
|
26
|
-
:example.html
|
|
27
|
-
<button id="myButton" onclick="document.getElementById('someText').innerHTML='I was clicked'">Click me</button>
|
|
28
|
-
<div id="someText">I was not clicked</div>
|
|
29
|
-
:click.js
|
|
30
|
-
it('should demonstrate the click command', () => {
|
|
31
|
-
const myButton = $('#myButton')
|
|
32
|
-
myButton.click()
|
|
33
|
-
const myText = $('#someText')
|
|
34
|
-
const text = myText.getText();
|
|
35
|
-
assert(text === 'I was clicked'); // true
|
|
36
|
-
})
|
|
37
|
-
:example.js
|
|
38
|
-
it('should fetch menu links and visit each page', () => {
|
|
39
|
-
const links = $$('#menu a');
|
|
40
|
-
links.forEach((link) => {
|
|
41
|
-
link.click();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
* </example>
|
|
45
|
-
*
|
|
46
|
-
* @alias element.click
|
|
47
|
-
* @uses protocol/element, protocol/elementIdClick
|
|
48
|
-
* @type action
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
8
|
function click() {
|
|
52
9
|
return this.elementClick(this.elementId);
|
|
53
10
|
}
|
|
@@ -5,41 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = doubleClick;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Double-click on an element.
|
|
11
|
-
*
|
|
12
|
-
* <example>
|
|
13
|
-
:example.html
|
|
14
|
-
<button id="myButton" ondblclick="document.getElementById('someText').innerHTML='I was dblclicked'">Click me</button>
|
|
15
|
-
<div id="someText">I was not clicked</div>
|
|
16
|
-
:doubleClick.js
|
|
17
|
-
it('should demonstrate the doubleClick command', () => {
|
|
18
|
-
const myButton = $('#myButton')
|
|
19
|
-
myButton.doubleClick()
|
|
20
|
-
|
|
21
|
-
const value = myButton.getText()
|
|
22
|
-
assert(value === 'I was dblclicked') // true
|
|
23
|
-
})
|
|
24
|
-
* </example>
|
|
25
|
-
*
|
|
26
|
-
* @alias element.doubleClick
|
|
27
|
-
* @uses protocol/element, protocol/moveTo, protocol/doDoubleClick, protocol/touchDoubleClick
|
|
28
|
-
* @type action
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
8
|
async function doubleClick() {
|
|
32
|
-
/**
|
|
33
|
-
* move to element
|
|
34
|
-
*/
|
|
35
9
|
if (!this.isW3C) {
|
|
36
10
|
await this.moveTo();
|
|
37
11
|
return this.positionDoubleClick();
|
|
38
12
|
}
|
|
39
|
-
/**
|
|
40
|
-
* W3C way of handle the double click actions
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
13
|
|
|
44
14
|
await this.performActions([{
|
|
45
15
|
type: 'pointer',
|
|
@@ -7,17 +7,6 @@ exports.default = dragAndDrop;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Drag an item to a destination element.
|
|
13
|
-
*
|
|
14
|
-
* @alias element.dragAndDrop
|
|
15
|
-
* @param {Element} target destination selector
|
|
16
|
-
* @param {Number=} duration how long the drag should take place
|
|
17
|
-
* @uses action/moveToObject, protocol/buttonDown, protocol/buttonUp, property/getLocation, protocol/touchDown, protocol/touchMove, protocol/touchUp
|
|
18
|
-
* @type action
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
10
|
const ACTION_BUTTON = 0;
|
|
22
11
|
|
|
23
12
|
async function dragAndDrop(target, duration = 100) {
|
|
@@ -31,10 +20,6 @@ async function dragAndDrop(target, duration = 100) {
|
|
|
31
20
|
await target.moveTo();
|
|
32
21
|
return this.buttonUp(ACTION_BUTTON);
|
|
33
22
|
}
|
|
34
|
-
/**
|
|
35
|
-
* get coordinates to drag and drop
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
23
|
|
|
39
24
|
const sourceRect = await (0, _utils.getElementRect)(this);
|
|
40
25
|
const targetRect = await (0, _utils.getElementRect)(target);
|
|
@@ -42,10 +27,6 @@ async function dragAndDrop(target, duration = 100) {
|
|
|
42
27
|
const sourceY = parseInt(sourceRect.y + sourceRect.height / 2, 10);
|
|
43
28
|
const targetX = parseInt(targetRect.x + targetRect.width / 2, 10) - sourceX;
|
|
44
29
|
const targetY = parseInt(targetRect.y + targetRect.height / 2, 10) - sourceY;
|
|
45
|
-
/**
|
|
46
|
-
* W3C way of handle the drag and drop action
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
30
|
return this.performActions([{
|
|
50
31
|
type: 'pointer',
|
|
51
32
|
id: 'finger1',
|
|
@@ -63,8 +44,7 @@ async function dragAndDrop(target, duration = 100) {
|
|
|
63
44
|
}, {
|
|
64
45
|
type: 'pause',
|
|
65
46
|
duration: 10
|
|
66
|
-
},
|
|
67
|
-
{
|
|
47
|
+
}, {
|
|
68
48
|
type: 'pointerMove',
|
|
69
49
|
duration,
|
|
70
50
|
origin: 'pointer',
|
|
@@ -5,32 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getAttribute;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Get an attribute from a DOM-element based on the attribute name.
|
|
11
|
-
*
|
|
12
|
-
* <example>
|
|
13
|
-
:index.html
|
|
14
|
-
<form action="/submit" method="post" class="loginForm">
|
|
15
|
-
<input type="text" name="name" placeholder="username"></input>
|
|
16
|
-
<input type="text" name="password" placeholder="password"></input>
|
|
17
|
-
<input type="submit" name="submit" value="submit"></input>
|
|
18
|
-
</form>
|
|
19
|
-
:getAttribute.js
|
|
20
|
-
it('should demonstrate the getAttribute command', () => {
|
|
21
|
-
const form = $('form')
|
|
22
|
-
const attr = form.getAttribute('method')
|
|
23
|
-
console.log(attr) // outputs: "post"
|
|
24
|
-
})
|
|
25
|
-
* </example>
|
|
26
|
-
*
|
|
27
|
-
* @alias element.getAttribute
|
|
28
|
-
* @param {String} attributeName requested attribute
|
|
29
|
-
* @return {String|null} The value of the attribute, or null if it is not set on the element.
|
|
30
|
-
* @uses protocol/elements, protocol/elementIdAttribute
|
|
31
|
-
* @type property
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
8
|
function getAttribute(attributeName) {
|
|
35
9
|
return this.getElementAttribute(this.elementId, attributeName);
|
|
36
10
|
}
|
|
@@ -7,72 +7,6 @@ exports.default = getCSSProperty;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Get a css property from a DOM-element selected by given selector. The return value
|
|
13
|
-
* is formatted to be testable. Colors gets parsed via [rgb2hex](https://www.npmjs.org/package/rgb2hex)
|
|
14
|
-
* and all other properties get parsed via [css-value](https://www.npmjs.org/package/css-value).
|
|
15
|
-
*
|
|
16
|
-
* Note that shorthand CSS properties (e.g. background, font, border, margin, padding, list-style, outline,
|
|
17
|
-
* pause, cue) are not returned, in accordance with the DOM CSS2 specification - you should directly access
|
|
18
|
-
* the longhand properties (e.g. background-color) to access the desired values.
|
|
19
|
-
*
|
|
20
|
-
* <example>
|
|
21
|
-
:example.html
|
|
22
|
-
<label id="myLabel" for="input" style="color: #0088cc; font-family: helvetica, arial, freesans, clean, sans-serif, width: 100px">Some Label</label>
|
|
23
|
-
:getCSSProperty.js
|
|
24
|
-
it('should demonstrate the getCSSProperty command', () => {
|
|
25
|
-
const elem = $('#myLabel')
|
|
26
|
-
const color = elem.getCSSProperty('color')
|
|
27
|
-
console.log(color)
|
|
28
|
-
// outputs the following:
|
|
29
|
-
// {
|
|
30
|
-
// property: 'color',
|
|
31
|
-
// value: 'rgba(0, 136, 204, 1)',
|
|
32
|
-
// parsed: {
|
|
33
|
-
// hex: '#0088cc',
|
|
34
|
-
// alpha: 1,
|
|
35
|
-
// type: 'color',
|
|
36
|
-
// rgba: 'rgba(0, 136, 204, 1)'
|
|
37
|
-
// }
|
|
38
|
-
// }
|
|
39
|
-
|
|
40
|
-
const font = elem.getCSSProperty('font-family')
|
|
41
|
-
console.log(font)
|
|
42
|
-
// outputs the following:
|
|
43
|
-
// {
|
|
44
|
-
// property: 'font-family',
|
|
45
|
-
// value: 'helvetica',
|
|
46
|
-
// parsed: {
|
|
47
|
-
// value: [ 'helvetica', 'arial', 'freesans', 'clean', 'sans-serif' ],
|
|
48
|
-
// type: 'font',
|
|
49
|
-
// string: 'helvetica, arial, freesans, clean, sans-serif'
|
|
50
|
-
// }
|
|
51
|
-
// }
|
|
52
|
-
|
|
53
|
-
var width = elem.getCSSProperty('width')
|
|
54
|
-
console.log(width)
|
|
55
|
-
// outputs the following:
|
|
56
|
-
// {
|
|
57
|
-
// property: 'width',
|
|
58
|
-
// value: '100px',
|
|
59
|
-
// parsed: {
|
|
60
|
-
// type: 'number',
|
|
61
|
-
// string: '100px',
|
|
62
|
-
// unit: 'px',
|
|
63
|
-
// value: 100
|
|
64
|
-
// }
|
|
65
|
-
// }
|
|
66
|
-
})
|
|
67
|
-
* </example>
|
|
68
|
-
*
|
|
69
|
-
* @alias element.getCSSProperty
|
|
70
|
-
* @param {String} cssProperty css property name
|
|
71
|
-
* @return {Object} The specified css of the element
|
|
72
|
-
* @uses protocol/elements, protocol/elementIdCssProperty
|
|
73
|
-
* @type property
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
10
|
async function getCSSProperty(cssProperty) {
|
|
77
11
|
const cssValue = await this.getElementCSSValue(this.elementId, cssProperty);
|
|
78
12
|
return (0, _utils.parseCSS)(cssValue, cssProperty);
|
|
@@ -13,41 +13,9 @@ var _getHTML = _interopRequireDefault(require("../../scripts/getHTML"));
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* Get source code of specified DOM element by selector.
|
|
19
|
-
*
|
|
20
|
-
* <example>
|
|
21
|
-
:index.html
|
|
22
|
-
<div id="test">
|
|
23
|
-
<span>Lorem ipsum dolor amet</span>
|
|
24
|
-
</div>
|
|
25
|
-
:getHTML.js
|
|
26
|
-
it('should get html for certain elements', () => {
|
|
27
|
-
var outerHTML = $('#test').getHTML();
|
|
28
|
-
console.log(outerHTML);
|
|
29
|
-
// outputs:
|
|
30
|
-
// "<div id="test"><span>Lorem ipsum dolor amet</span></div>"
|
|
31
|
-
|
|
32
|
-
var innerHTML = $('#test').getHTML(false);
|
|
33
|
-
console.log(innerHTML);
|
|
34
|
-
// outputs:
|
|
35
|
-
// "<span>Lorem ipsum dolor amet</span>"
|
|
36
|
-
});
|
|
37
|
-
* </example>
|
|
38
|
-
*
|
|
39
|
-
* @alias element.getHTML
|
|
40
|
-
* @param {Boolean=} includeSelectorTag if true it includes the selector element tag (default: true)
|
|
41
|
-
* @return {String} the HTML of the specified element
|
|
42
|
-
* @uses action/selectorExecute
|
|
43
|
-
* @type property
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
16
|
function getHTML(includeSelectorTag = true) {
|
|
47
17
|
return (0, _utils.getBrowserObject)(this).execute(_getHTML.default, {
|
|
48
18
|
[_constants.ELEMENT_KEY]: this.elementId,
|
|
49
|
-
|
|
50
|
-
ELEMENT: this.elementId // jsonwp compatible
|
|
51
|
-
|
|
19
|
+
ELEMENT: this.elementId
|
|
52
20
|
}, includeSelectorTag);
|
|
53
21
|
}
|
|
@@ -7,33 +7,6 @@ exports.default = getLocation;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Determine an element’s location on the page. The point (0, 0) refers to
|
|
13
|
-
* the upper-left corner of the page.
|
|
14
|
-
*
|
|
15
|
-
* <example>
|
|
16
|
-
:getLocation.js
|
|
17
|
-
it('should demonstrate the getLocation function', () => {
|
|
18
|
-
browser.url('http://github.com');
|
|
19
|
-
const logo = $('.octicon-mark-github')
|
|
20
|
-
const location = logo.getLocation();
|
|
21
|
-
console.log(location); // outputs: { x: 150, y: 20 }
|
|
22
|
-
|
|
23
|
-
const xLocation = logo.getLocation('x')
|
|
24
|
-
console.log(xLocation); // outputs: 150
|
|
25
|
-
|
|
26
|
-
const yLocation = logo.getLocation('.octicon-mark-github', 'y')
|
|
27
|
-
console.log(yLocation); // outputs: 20
|
|
28
|
-
});
|
|
29
|
-
* </example>
|
|
30
|
-
*
|
|
31
|
-
* @alias element.getLocation
|
|
32
|
-
* @param {String} prop can be "x" or "y" to get a result value directly for easier assertions
|
|
33
|
-
* @return {Object|Number} The X and Y coordinates for the element on the page (`{x:number, y:number}`)
|
|
34
|
-
* @uses protocol/elementIdLocation
|
|
35
|
-
* @type property
|
|
36
|
-
*/
|
|
37
10
|
async function getLocation(prop) {
|
|
38
11
|
let location = {};
|
|
39
12
|
|
|
@@ -11,22 +11,6 @@ var _getProperty = _interopRequireDefault(require("../../scripts/getProperty"));
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* The Get Element Property command will return the result of getting a property of an element.
|
|
16
|
-
*
|
|
17
|
-
* <example>
|
|
18
|
-
:getProperty.js
|
|
19
|
-
it('should demonstrate the getCSSProperty command', () => {
|
|
20
|
-
var elem = $('body')
|
|
21
|
-
var color = elem.getProperty('tagName')
|
|
22
|
-
console.log(color) // outputs: "BODY"
|
|
23
|
-
})
|
|
24
|
-
* </example>
|
|
25
|
-
*
|
|
26
|
-
* @alias element.getProperty
|
|
27
|
-
* @param {String} property name of the element property
|
|
28
|
-
* @return {Object|String} the value of the property of the selected element
|
|
29
|
-
*/
|
|
30
14
|
function getProperty(property) {
|
|
31
15
|
if (this.isW3C) {
|
|
32
16
|
return this.getElementProperty(this.elementId, property);
|
|
@@ -7,33 +7,6 @@ exports.default = getSize;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Get the width and height for an DOM-element.
|
|
13
|
-
*
|
|
14
|
-
* <example>
|
|
15
|
-
:getSize.js
|
|
16
|
-
it('should demonstrate the getSize command', () => {
|
|
17
|
-
browser.url('http://github.com')
|
|
18
|
-
const logo = $('.octicon-mark-github')
|
|
19
|
-
|
|
20
|
-
const size = logo.getSize()
|
|
21
|
-
console.log(size) // outputs: { width: 32, height: 32 }
|
|
22
|
-
|
|
23
|
-
const width = logo.getSize('width')
|
|
24
|
-
console.log(width) // outputs: 32
|
|
25
|
-
|
|
26
|
-
const height = logo.getSize('height')
|
|
27
|
-
console.log(height) // outputs: 32
|
|
28
|
-
})
|
|
29
|
-
* </example>
|
|
30
|
-
*
|
|
31
|
-
* @alias element.getElementSize
|
|
32
|
-
* @param {String=} prop size to receive [optional] ("width" or "height")
|
|
33
|
-
* @return {Object|Number} requested element size (`{ width: <Number>, height: <Number> }`) or actual width/height as number if prop param is given
|
|
34
|
-
* @type property
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
10
|
async function getSize(prop = null) {
|
|
38
11
|
let rect = {};
|
|
39
12
|
|
|
@@ -5,29 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getTagName;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Get tag name of a DOM-element.
|
|
11
|
-
*
|
|
12
|
-
* <example>
|
|
13
|
-
:index.html
|
|
14
|
-
<div id="elem">Lorem ipsum</div>
|
|
15
|
-
|
|
16
|
-
:getTagName.js
|
|
17
|
-
it('should demonstrate the getTagName command', () => {
|
|
18
|
-
const elem = $('#elem');
|
|
19
|
-
|
|
20
|
-
const tagName = elem.getTagName();
|
|
21
|
-
console.log(tagName); // outputs: "div"
|
|
22
|
-
})
|
|
23
|
-
* </example>
|
|
24
|
-
*
|
|
25
|
-
* @alias element.getTagName
|
|
26
|
-
* @return {String} the element's tag name, as a lowercase string
|
|
27
|
-
* @uses protocol/elements, protocol/elementIdName
|
|
28
|
-
* @type property
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
8
|
function getTagName() {
|
|
32
9
|
return this.getElementTagName(this.elementId);
|
|
33
10
|
}
|
|
@@ -5,46 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getText;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Get the text content from a DOM-element. Make sure the element
|
|
11
|
-
* you want to request the text from [is interactable](http://www.w3.org/TR/webdriver/#interactable)
|
|
12
|
-
* otherwise you will get an empty string as return value. If the element is disabled or not
|
|
13
|
-
* visible and you still want to receive the text content use [getHTML](https://webdriver.io/docs/api/element/getHTML.html)
|
|
14
|
-
* as a workaround.
|
|
15
|
-
*
|
|
16
|
-
* <example>
|
|
17
|
-
:index.html
|
|
18
|
-
<div id="elem">
|
|
19
|
-
Lorem ipsum <strong>dolor</strong> sit amet,<br>
|
|
20
|
-
consetetur sadipscing elitr
|
|
21
|
-
</div>
|
|
22
|
-
<span style="display: none">I am invisible</span>
|
|
23
|
-
:getText.js
|
|
24
|
-
it('should demonstrate the getText function', () => {
|
|
25
|
-
const elem = $('#elem');
|
|
26
|
-
console.log(elem.getText());
|
|
27
|
-
// outputs the following:
|
|
28
|
-
// "Lorem ipsum dolor sit amet,consetetur sadipscing elitr"
|
|
29
|
-
|
|
30
|
-
const span = $('span');
|
|
31
|
-
console.log(span.getText());
|
|
32
|
-
// outputs "" (empty string) since element is not interactable
|
|
33
|
-
});
|
|
34
|
-
it('get content from table cell', () => {
|
|
35
|
-
browser.url('http://the-internet.herokuapp.com/tables');
|
|
36
|
-
const rows = $$('#table1 tr');
|
|
37
|
-
const columns = rows[1].$$('td'); // get columns of 2nd row
|
|
38
|
-
console.log(columns[2].getText()); // get text of 3rd column
|
|
39
|
-
});
|
|
40
|
-
* </example>
|
|
41
|
-
*
|
|
42
|
-
* @alias element.getText
|
|
43
|
-
* @return {String} content of selected element (all HTML tags are removed)
|
|
44
|
-
* @uses protocol/elements, protocol/elementIdText
|
|
45
|
-
* @type property
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
8
|
function getText() {
|
|
49
9
|
return this.getElementText(this.elementId);
|
|
50
10
|
}
|