Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ariaRole() as alias for getAriaRole() #4159

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading