Skip to content

Commit 4e96560

Browse files
committed
Call execute to print page
1 parent 67631f7 commit 4e96560

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

java/client/src/org/openqa/selenium/printoptions/PrintOptions.java

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.openqa.selenium.printoptions;
1919

20+
import java.util.Map;
21+
2022
public class PrintOptions {
2123

2224
public enum PrintOrientation {
@@ -89,4 +91,8 @@ public PageSize getPageSize() {
8991
public PageMargin getPageMargin() {
9092
return this.pageMargin;
9193
}
94+
95+
public Map<String, String> to_json() {
96+
return null;
97+
}
9298
}

java/client/src/org/openqa/selenium/remote/DriverCommand.java

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.openqa.selenium.Point;
2626
import org.openqa.selenium.WindowType;
2727
import org.openqa.selenium.interactions.Sequence;
28+
import org.openqa.selenium.printoptions.PrintOptions;
2829

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

228229
String SET_TIMEOUT = "setTimeout";
229230

231+
String PRINT_PAGE = "printPage";
232+
static CommandPayload PRINT_PAGE(PrintOptions options) {
233+
return new CommandPayload(PRINT_PAGE, options.to_json());
234+
}
235+
230236
@Deprecated
231237
static CommandPayload SET_IMPLICIT_WAIT_TIMEOUT(long time, TimeUnit unit) {
232238
return new CommandPayload(

java/client/src/org/openqa/selenium/remote/RemoteWebDriver.java

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
import org.openqa.selenium.logging.LoggingPreferences;
7878
import org.openqa.selenium.logging.Logs;
7979
import org.openqa.selenium.logging.NeedsLocalLogs;
80+
import org.openqa.selenium.printoptions.PrintOptions;
8081
import org.openqa.selenium.remote.internal.WebElementToJsonConverter;
8182
import org.openqa.selenium.virtualauthenticator.Credential;
8283
import org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator;
@@ -331,6 +332,11 @@ public WebElement findElement(By locator) {
331332
}
332333
}
333334

335+
public String printPage(PrintOptions options) {
336+
Response response = execute(DriverCommand.PRINT_PAGE(options));
337+
338+
return (String) response.getValue();
339+
}
334340
@Override
335341
public List<WebElement> findElements(By locator) {
336342
if (locator instanceof By.StandardLocator) {

java/client/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java

+2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ public W3CHttpCommandCodec() {
154154
defineCommand(GET_ALERT_TEXT, get(alert + "/text"));
155155
defineCommand(SET_ALERT_VALUE, post(alert + "/text"));
156156

157+
defineCommand(PRINT_PAGE, post(sessionId + "/print"));
158+
157159
defineCommand(UPLOAD_FILE, post(sessionId + "/se/file"));
158160

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

0 commit comments

Comments
 (0)