diff --git a/lib/api/web-element/scoped-element.js b/lib/api/web-element/scoped-element.js index 539e01276..ee0aae196 100644 --- a/lib/api/web-element/scoped-element.js +++ b/lib/api/web-element/scoped-element.js @@ -27,7 +27,7 @@ class ScopedWebElement { 'getText': ['text'], 'getTagName': ['tagName'], 'getAccessibleName': ['accessibleName'], - 'getCssProperty': ['css'], + 'getCssProperty': ['css', 'getCssValue'], 'getAriaRole': ['ariaRole'], 'isVisible': ['isDisplayed'] }; diff --git a/test/src/api/commands/web-element/testGetCssProperty.js b/test/src/api/commands/web-element/testGetCssProperty.js index 3a29befa2..fc4743993 100644 --- a/test/src/api/commands/web-element/testGetCssProperty.js +++ b/test/src/api/commands/web-element/testGetCssProperty.js @@ -63,6 +63,30 @@ describe('element().getCssProperty() command', function () { assert.strictEqual(resultValue, '150px'); }); + it('test .element().getCssValue() alias', async function() { + MockServer.addMock({ + url: '/session/13521-10219-202/element/0/css/height', + method: 'GET', + response: JSON.stringify({ + value: '150px' + }) + }, true); + + const resultPromise = this.client.api.element('#signupSection').getCssValue('height'); + 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, '150px'); + + const resultValue = await resultPromise.value; + assert.strictEqual(resultValue, '150px'); + }); + it('test .element().find().getCssProperty()', async function() { MockServer.addMock({ url: '/session/13521-10219-202/element/1/css/height', @@ -135,4 +159,5 @@ describe('element().getCssProperty() command', function () { assert.strictEqual(await resultPromise.assert.not.contains('150x'), '150px'); assert.strictEqual(await resultPromise.assert.not.matches(/150[a-z]{2}x/), '150px'); }); + }); diff --git a/types/tests/webElement.test-d.ts b/types/tests/webElement.test-d.ts index 17b58b6e0..4cd24eb6f 100644 --- a/types/tests/webElement.test-d.ts +++ b/types/tests/webElement.test-d.ts @@ -167,6 +167,8 @@ describe('new element() api', function () { expectType>(elem.getAriaRole()); expectType>(elem.ariaRole()); expectType>(elem.getCssProperty('height')); + expectType>(elem.css('height')); + expectType>(elem.getCssValue('height')); expectType>(elem.takeScreenshot()); expectType>(elem.click()); diff --git a/types/web-element.d.ts b/types/web-element.d.ts index f2e6de632..90ddf1efa 100644 --- a/types/web-element.d.ts +++ b/types/web-element.d.ts @@ -188,6 +188,8 @@ export interface ScopedElement extends Element, PromiseLike { ariaRole(): ElementValue; getCssProperty(name: string): ElementValue; + css(name: string): ElementValue; + getCssValue(name: string): ElementValue; getValue(): ElementValue;