Skip to content

Commit

Permalink
[bidi][java] Add browsing context capture screenshot method
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Sep 20, 2023
1 parent 465bb1e commit 83a27e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,10 @@ public void handleUserPrompt(boolean accept, String userText) {
ImmutableMap.of(CONTEXT, id, "accept", accept, "userText", userText)));
}

// Yet to be implemented by browser vendors
private String captureScreenshot() {
public String captureScreenshot() {
return this.bidi.send(
new Command<>(
HANDLE_USER_PROMPT,
"browsingContext.captureScreenshot",
ImmutableMap.of(CONTEXT, id),
jsonInput -> {
Map<String, Object> result = jsonInput.read(Map.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,19 @@ void canDismissUserPromptWithUserText() {
assertThat(driver.getPageSource()).doesNotContain(userText);
}

@Test
@NotYetImplemented(SAFARI)
@NotYetImplemented(IE)
void canCaptureScreenshot() {
BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle());

driver.get(pages.simpleTestPage);

String screenshot = browsingContext.captureScreenshot();

assertThat(screenshot.length()).isPositive();
}

private String alertPage() {
return appServer.create(
new Page()
Expand Down

0 comments on commit 83a27e7

Please sign in to comment.