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
|
@@ -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
|
}
|
|
@@ -5,31 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getValue;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Get the value of a `<textarea>`, `<select>` or text `<input>` found by given selector.
|
|
11
|
-
* If multiple elements are found via the given selector, an array of values is returned instead.
|
|
12
|
-
* For input with checkbox or radio type use isSelected.
|
|
13
|
-
*
|
|
14
|
-
* <example>
|
|
15
|
-
:index.html
|
|
16
|
-
<input type="text" value="John Doe" id="username">
|
|
17
|
-
:getValue.js
|
|
18
|
-
it('should demonstrate the getValue command', () => {
|
|
19
|
-
const inputUser = $('#username');
|
|
20
|
-
const value = inputUser.getValue();
|
|
21
|
-
console.log(value); // outputs: "John Doe"
|
|
22
|
-
});
|
|
23
|
-
* </example>
|
|
24
|
-
*
|
|
25
|
-
* @alias element.getValue
|
|
26
|
-
* @return {String} requested element(s) value
|
|
27
|
-
* @uses protocol/elements, protocol/elementIdProperty
|
|
28
|
-
* @type property
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
8
|
function getValue() {
|
|
32
|
-
// `!this.isMobile` added to workaround https://github.com/appium/appium/issues/12218
|
|
33
9
|
if (this.isW3C && !this.isMobile) {
|
|
34
10
|
return this.getElementProperty(this.elementId, 'value');
|
|
35
11
|
}
|
|
@@ -13,82 +13,21 @@ var _isElementDisplayed = _interopRequireDefault(require("../../scripts/isElemen
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* Return true if the selected DOM-element is displayed.
|
|
19
|
-
*
|
|
20
|
-
* <example>
|
|
21
|
-
:index.html
|
|
22
|
-
<div id="notDisplayed" style="display: none"></div>
|
|
23
|
-
<div id="notVisible" style="visibility: hidden"></div>
|
|
24
|
-
<div id="notInViewport" style="position:absolute; left: 9999999"></div>
|
|
25
|
-
<div id="zeroOpacity" style="opacity: 0"></div>
|
|
26
|
-
:isDisplayed.js
|
|
27
|
-
it('should detect if an element is displayed', () => {
|
|
28
|
-
let elem = $('#notDisplayed');
|
|
29
|
-
let isDisplayed = elem.isDisplayed();
|
|
30
|
-
console.log(isDisplayed); // outputs: false
|
|
31
|
-
|
|
32
|
-
elem = $('#notVisible');
|
|
33
|
-
|
|
34
|
-
isDisplayed = elem.isDisplayed();
|
|
35
|
-
console.log(isDisplayed); // outputs: false
|
|
36
|
-
|
|
37
|
-
elem = $('#notExisting');
|
|
38
|
-
isDisplayed = elem.isDisplayed();
|
|
39
|
-
console.log(isDisplayed); // outputs: false
|
|
40
|
-
|
|
41
|
-
elem = $('#notInViewport');
|
|
42
|
-
isDisplayed = elem.isDisplayed();
|
|
43
|
-
console.log(isDisplayed); // outputs: true
|
|
44
|
-
|
|
45
|
-
elem = $('#zeroOpacity');
|
|
46
|
-
isDisplayed = elem.isDisplayed();
|
|
47
|
-
console.log(isDisplayed); // outputs: true
|
|
48
|
-
});
|
|
49
|
-
* </example>
|
|
50
|
-
*
|
|
51
|
-
* @alias element.isDisplayed
|
|
52
|
-
* @return {Boolean} true if element is displayed
|
|
53
|
-
* @uses protocol/elements, protocol/elementIdDisplayed
|
|
54
|
-
* @type state
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
16
|
const noW3CEndpoint = ['microsoftedge', 'safari', 'chrome'];
|
|
58
17
|
|
|
59
18
|
async function isDisplayed() {
|
|
60
19
|
let browser = (0, _utils.getBrowserObject)(this);
|
|
61
|
-
/*
|
|
62
|
-
* This is only necessary as isDisplayed is on the exclusion list for the middleware
|
|
63
|
-
*/
|
|
64
20
|
|
|
65
21
|
if (!this.elementId) {
|
|
66
22
|
this.elementId = (await this.parent.$(this.selector)).elementId;
|
|
67
23
|
}
|
|
68
|
-
/*
|
|
69
|
-
* if element was still not found it also is not displayed
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
24
|
|
|
73
25
|
if (!this.elementId) {
|
|
74
26
|
return false;
|
|
75
27
|
}
|
|
76
|
-
/*
|
|
77
|
-
* https://www.w3.org/TR/webdriver/#element-displayedness
|
|
78
|
-
* Certain drivers have decided to remove the endpoint as the spec
|
|
79
|
-
* no longer dictates it. In those instances, we pass the element through a script
|
|
80
|
-
* that was provided by Brian Burg of safaridriver.
|
|
81
|
-
*
|
|
82
|
-
* 6th of May 2019 APPIUM response (mykola-mokhnach) :
|
|
83
|
-
* - Appium didn't enable W3C mode for mobile drivers.
|
|
84
|
-
* - Safari and Chrome work in jsonwp mode and Appium just rewrites W3C requests from upstream to jsonwp if needed
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
28
|
|
|
88
29
|
return browser.isW3C && !browser.isMobile && noW3CEndpoint.includes(browser.capabilities.browserName.toLowerCase()) ? await browser.execute(_isElementDisplayed.default, {
|
|
89
30
|
[_constants.ELEMENT_KEY]: this.elementId,
|
|
90
|
-
|
|
91
|
-
ELEMENT: this.elementId // jsonwp compatible
|
|
92
|
-
|
|
31
|
+
ELEMENT: this.elementId
|
|
93
32
|
}) : await this.isElementDisplayed(this.elementId);
|
|
94
33
|
}
|