Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/java/io/appium/java_client/AppiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ImmutableCapabilities;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.SessionNotCreatedException;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.CapabilityType;
Expand Down Expand Up @@ -270,4 +271,24 @@ public Response execute(String driverCommand, Map<String, ?> parameters) {
public Response execute(String command) {
return super.execute(command, Collections.emptyMap());
}

@Override
public <X> X getScreenshotAs(OutputType<X> outputType) {
// TODO: Eventually we should not override this method.
// TODO: Although, we have a legacy burden,
// TODO: so it's impossible to do it the other way as of Oct 29 2022.
// TODO: See https://github.com/SeleniumHQ/selenium/issues/11168
return super.getScreenshotAs(new OutputType<X>() {
@Override
public X convertFromBase64Png(String base64Png) {
String rfc4648Base64 = base64Png.replaceAll("\\r?\\n", "");
return outputType.convertFromBase64Png(rfc4648Base64);
}

@Override
public X convertFromPngBytes(byte[] png) {
return outputType.convertFromPngBytes(png);
}
});
}
}