Skip to content

Commit 83a27e7

Browse files
committed
[bidi][java] Add browsing context capture screenshot method
1 parent 465bb1e commit 83a27e7

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,10 @@ public void handleUserPrompt(boolean accept, String userText) {
213213
ImmutableMap.of(CONTEXT, id, "accept", accept, "userText", userText)));
214214
}
215215

216-
// Yet to be implemented by browser vendors
217-
private String captureScreenshot() {
216+
public String captureScreenshot() {
218217
return this.bidi.send(
219218
new Command<>(
220-
HANDLE_USER_PROMPT,
219+
"browsingContext.captureScreenshot",
221220
ImmutableMap.of(CONTEXT, id),
222221
jsonInput -> {
223222
Map<String, Object> result = jsonInput.read(Map.class);

java/test/org/openqa/selenium/bidi/browsingcontext/BrowsingContextTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,19 @@ void canDismissUserPromptWithUserText() {
336336
assertThat(driver.getPageSource()).doesNotContain(userText);
337337
}
338338

339+
@Test
340+
@NotYetImplemented(SAFARI)
341+
@NotYetImplemented(IE)
342+
void canCaptureScreenshot() {
343+
BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle());
344+
345+
driver.get(pages.simpleTestPage);
346+
347+
String screenshot = browsingContext.captureScreenshot();
348+
349+
assertThat(screenshot.length()).isPositive();
350+
}
351+
339352
private String alertPage() {
340353
return appServer.create(
341354
new Page()

0 commit comments

Comments
 (0)