diff --git a/lib/api/web-element/commands/getAccessibleName.js b/lib/api/web-element/commands/getAccessibleName.js index ac531f1d7..cf641333a 100644 --- a/lib/api/web-element/commands/getAccessibleName.js +++ b/lib/api/web-element/commands/getAccessibleName.js @@ -20,9 +20,11 @@ * @method getAccessibleName * @memberof ScopedWebElement * @instance - * @syntax browser.element(selector).getAccessibleName() + * @syntax browser.element.find(selector).getAccessibleName() + * @syntax browser.element.find(selector).getComputedLabel() * @link /#get-computed-label * @returns {ScopedValue} A container with accessible name of an element. + * @alias getComputedLabel */ module.exports.command = function() { return this.runQueuedCommandScoped('getElementAccessibleName'); diff --git a/lib/api/web-element/commands/getAriaRole.js b/lib/api/web-element/commands/getAriaRole.js index 68ac1a780..b9c04cb2d 100644 --- a/lib/api/web-element/commands/getAriaRole.js +++ b/lib/api/web-element/commands/getAriaRole.js @@ -19,9 +19,11 @@ * @method getAriaRole * @memberof ScopedWebElement * @instance - * @syntax browser.element(selector).getAriaRole() + * @syntax browser.element.find(selector).getAriaRole() + * @syntax browser.element.find(selector).getComputedRole() * @link /#get-computed-role * @returns {ScopedValue} The container with computed WAI-ARIA role of an element. + * @alias getComputedRole */ module.exports.command = function() { return this.runQueuedCommandScoped('getElementAriaRole'); diff --git a/lib/api/web-element/scoped-element.js b/lib/api/web-element/scoped-element.js index 8dffc0b8f..3d2e55eed 100644 --- a/lib/api/web-element/scoped-element.js +++ b/lib/api/web-element/scoped-element.js @@ -27,9 +27,9 @@ class ScopedWebElement { 'getProperty': ['property', 'prop'], 'getText': ['text'], 'getTagName': ['tagName'], - 'getAccessibleName': ['accessibleName'], + 'getAccessibleName': ['accessibleName', 'getComputedLabel'], 'getCssProperty': ['css', 'getCssValue'], - 'getAriaRole': ['ariaRole'], + 'getAriaRole': ['ariaRole', 'getComputedRole'], 'isVisible': ['isDisplayed'] }; } diff --git a/test/src/api/commands/web-element/testGetAccessibleName.js b/test/src/api/commands/web-element/testGetAccessibleName.js index 5b3bca5a7..cd1c820b5 100644 --- a/test/src/api/commands/web-element/testGetAccessibleName.js +++ b/test/src/api/commands/web-element/testGetAccessibleName.js @@ -65,6 +65,31 @@ describe('element().getAccessibleName() command', function () { assert.strictEqual(resultValue, 'Signup'); }); + it('test .element().getComputedLabel() alias', async function() { + MockServer.addMock({ + url: '/session/13521-10219-202/element/0/computedlabel', + method: 'GET', + response: JSON.stringify({ + value: 'Signup' + }) + }, true); + + const resultPromise = this.client.api.element('#signupSection').getComputedLabel(); + assert.strictEqual(resultPromise instanceof Element, false); + assert.strictEqual(typeof resultPromise.find, 'undefined'); + + assert.strictEqual(resultPromise instanceof Promise, false); + assert.strictEqual(typeof resultPromise.then, 'function'); + assert.strictEqual(typeof resultPromise.value, 'object'); + + const result = await resultPromise; + assert.strictEqual(result instanceof WebElement, false); + assert.strictEqual(result, 'Signup'); + + const resultValue = await resultPromise.value; + assert.strictEqual(resultValue, 'Signup'); + }); + it('test .element().find().getAccessibleName()', async function() { MockServer.addMock({ url: '/session/13521-10219-202/element/1/computedlabel', diff --git a/test/src/api/commands/web-element/testGetAriaRole.js b/test/src/api/commands/web-element/testGetAriaRole.js index 7cddaad3c..005803b6e 100644 --- a/test/src/api/commands/web-element/testGetAriaRole.js +++ b/test/src/api/commands/web-element/testGetAriaRole.js @@ -38,7 +38,7 @@ describe('element().getAriaRole() command', function () { assert.strictEqual(resultValue, 'signupSection'); }); - it('test .element().ariaRole()', async function() { + it('test .element().ariaRole() alias', async function() { MockServer.addMock({ url: '/session/13521-10219-202/element/0/computedrole', method: 'GET', @@ -62,6 +62,30 @@ describe('element().getAriaRole() command', function () { assert.strictEqual(resultValue, 'signupSection'); }); + it('test .element().getComputedRole() alias', async function() { + MockServer.addMock({ + url: '/session/13521-10219-202/element/0/computedrole', + method: 'GET', + response: JSON.stringify({ + value: 'signupSection' + }) + }, true); + + const resultPromise = this.client.api.element('#signupSection').getComputedRole(); + assert.strictEqual(resultPromise instanceof Element, false); + assert.strictEqual(typeof resultPromise.find, 'undefined'); + + assert.strictEqual(resultPromise instanceof Promise, false); + assert.strictEqual(typeof resultPromise.then, 'function'); + + const result = await resultPromise; + assert.strictEqual(result instanceof WebElement, false); + assert.strictEqual(result, 'signupSection'); + + const resultValue = await resultPromise.value; + assert.strictEqual(resultValue, 'signupSection'); + }); + it('test .element().find().getAriaRole()', async function() { MockServer.addMock({ url: '/session/13521-10219-202/element/1/computedrole', diff --git a/types/tests/webElement.test-d.ts b/types/tests/webElement.test-d.ts index 1ddcc172b..41f232f7c 100644 --- a/types/tests/webElement.test-d.ts +++ b/types/tests/webElement.test-d.ts @@ -171,8 +171,10 @@ describe('new element() api', function () { expectType>(elem.getAccessibleName()); expectType>(elem.accessibleName()); + expectType>(elem.getComputedLabel()); expectType>(elem.getAriaRole()); expectType>(elem.ariaRole()); + expectType>(elem.getComputedRole()); expectType>(elem.getCssProperty('height')); expectType>(elem.css('height')); expectType>(elem.getCssValue('height')); diff --git a/types/web-element.d.ts b/types/web-element.d.ts index 426778068..005d082b2 100644 --- a/types/web-element.d.ts +++ b/types/web-element.d.ts @@ -188,9 +188,11 @@ export interface ScopedElement extends Element, PromiseLike { getAccessibleName(): ElementValue; accessibleName(): ElementValue; + getComputedLabel(): ElementValue; getAriaRole(): ElementValue; ariaRole(): ElementValue; + getComputedRole(): ElementValue; getCssProperty(name: string): ElementValue; css(name: string): ElementValue;