Skip to content

Commit

Permalink
Call execute to print page
Browse files Browse the repository at this point in the history
  • Loading branch information
raju249 committed Dec 28, 2020
1 parent ecd7450 commit e977ed1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.openqa.selenium.printoptions;

import java.util.Map;

public class PrintOptions {

public enum PrintOrientation {
Expand Down Expand Up @@ -89,4 +91,8 @@ public PageSize getPageSize() {
public PageMargin getPageMargin() {
return this.pageMargin;
}

public Map<String, String> to_json() {
return null;
}
}
6 changes: 6 additions & 0 deletions java/client/src/org/openqa/selenium/remote/DriverCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.openqa.selenium.Point;
import org.openqa.selenium.WindowType;
import org.openqa.selenium.interactions.Sequence;
import org.openqa.selenium.printoptions.PrintOptions;

import java.time.Duration;
import java.util.Collection;
Expand Down Expand Up @@ -227,6 +228,11 @@ static CommandPayload SET_ALERT_VALUE(String keysToSend) {

String SET_TIMEOUT = "setTimeout";

String PRINT_PAGE = "printPage";
static CommandPayload PRINT_PAGE(PrintOptions options) {
return new CommandPayload(PRINT_PAGE, options.to_json());
}

@Deprecated
static CommandPayload SET_IMPLICIT_WAIT_TIMEOUT(long time, TimeUnit unit) {
return new CommandPayload(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.openqa.selenium.logging.LoggingPreferences;
import org.openqa.selenium.logging.Logs;
import org.openqa.selenium.logging.NeedsLocalLogs;
import org.openqa.selenium.printoptions.PrintOptions;
import org.openqa.selenium.remote.internal.WebElementToJsonConverter;
import org.openqa.selenium.virtualauthenticator.Credential;
import org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator;
Expand Down Expand Up @@ -331,6 +332,11 @@ public WebElement findElement(By locator) {
}
}

public String printPage(PrintOptions options) {
Response response = execute(DriverCommand.PRINT_PAGE(options));

return (String) response.getValue();
}
@Override
public List<WebElement> findElements(By locator) {
if (locator instanceof By.StandardLocator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public W3CHttpCommandCodec() {
defineCommand(GET_ALERT_TEXT, get(alert + "/text"));
defineCommand(SET_ALERT_VALUE, post(alert + "/text"));

defineCommand(PRINT_PAGE, post(sessionId + "/print"));

defineCommand(UPLOAD_FILE, post(sessionId + "/se/file"));

defineCommand(GET_ACTIVE_ELEMENT, get(sessionId + "/element/active"));
Expand Down

0 comments on commit e977ed1

Please sign in to comment.