diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java index c1d23c8b9..2063436eb 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java @@ -245,7 +245,7 @@ public Locator getByPlaceholder(Pattern text, GetByPlaceholderOptions options) { @Override public Locator getByRole(AriaRole role, GetByRoleOptions options) { - return null; + return locator(getByRoleSelector(role, options)); } @Override diff --git a/playwright/src/test/java/com/microsoft/playwright/TestSelectorsGetBy.java b/playwright/src/test/java/com/microsoft/playwright/TestSelectorsGetBy.java index eb2706ac4..d086c2a55 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestSelectorsGetBy.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestSelectorsGetBy.java @@ -171,4 +171,12 @@ void getByRoleEscaping() { asList("he llo 56"), 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("
"); + assertEquals( + asList(""), + page.locator("div").getByRole(AriaRole.BUTTON).evaluateAll("els => els.map(e => e.outerHTML)")); + } }