Skip to content

Commit

Permalink
Add ariaRole() as alias for getAriaRole() (#4159)
Browse files Browse the repository at this point in the history
Co-authored-by: Priyansh Garg <[email protected]>
  • Loading branch information
Sajantoor and garg3133 authored Apr 17, 2024
1 parent 579a7e3 commit b7275e9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/api/web-element/scoped-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ScopedWebElement {
'getRect': ['getSize', 'getLocation', 'rect'],
'getProperty': ['property'],
'getCssProperty': ['css'],
'getAriaRole': ['ariaRole'],
'isVisible': ['isDisplayed']
};
}
Expand Down
24 changes: 24 additions & 0 deletions test/src/api/commands/web-element/testGetAriaRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,30 @@ describe('element().getAriaRole() command', function () {
assert.strictEqual(resultValue, 'signupSection');
});

it('test .element().ariaRole()', 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').ariaRole();
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',
Expand Down
1 change: 1 addition & 0 deletions types/tests/webElement.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ describe('new element() api', function () {

expectType<ElementValue<string>>(elem.getAccessibleName());
expectType<ElementValue<string>>(elem.getAriaRole());
expectType<ElementValue<string>>(elem.ariaRole());
expectType<ElementValue<string>>(elem.getCssProperty('height'));
expectType<ElementValue<string>>(elem.takeScreenshot());

Expand Down
1 change: 1 addition & 0 deletions types/web-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export interface ScopedElement extends Element, PromiseLike<WebElement> {
getAccessibleName(): ElementValue<string>;

getAriaRole(): ElementValue<string>;
ariaRole(): ElementValue<string>;

getCssProperty(name: string): ElementValue<string>;

Expand Down

0 comments on commit b7275e9

Please sign in to comment.