cherry-pick(#1131): fix: implement LocatorImpl.getByRole (#1132)

Fixes https://github.com/microsoft/playwright-java/issues/1130
This commit is contained in:
Yury Semikhatsky 2022-11-28 15:13:25 -08:00 committed by GitHub
parent e47d0ab16c
commit 04158db747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -245,7 +245,7 @@ class LocatorImpl implements Locator {
@Override
public Locator getByRole(AriaRole role, GetByRoleOptions options) {
return null;
return locator(getByRoleSelector(role, options));
}
@Override

View File

@ -171,4 +171,12 @@ public class TestSelectorsGetBy extends TestBase {
asList("<a href=\"https://playwright.dev\">he llo 56</a>"),
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName(" he \n llo 56 ").setExact(true)).evaluateAll("els => els.map(e => e.outerHTML)"));
}
@Test
void locatorGetByRole() {
page.setContent("<div><button>Click me</button></div>");
assertEquals(
asList("<button>Click me</button>"),
page.locator("div").getByRole(AriaRole.BUTTON).evaluateAll("els => els.map(e => e.outerHTML)"));
}
}