Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Bump Selenium version to 4.7.0 #1811

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
org.gradle.daemon=true

selenium.version=4.5.0
selenium.version=4.7.0
# Please increment the value in a release
appiumClient.version=8.2.1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.openqa.selenium.remote.ProtocolHandshake;
import org.openqa.selenium.remote.http.HttpHandler;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
Expand All @@ -39,6 +38,7 @@
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Stream;

import static java.nio.charset.StandardCharsets.UTF_8;
Expand All @@ -62,7 +62,7 @@ private static void writeJsonPayload(NewSessionPayload srcPayload, Appendable de
try {
Method getW3CMethod = NewSessionPayload.class.getDeclaredMethod("getW3C");
getW3CMethod.setAccessible(true);
//noinspection unchecked
//noinspection unchecked,resource
((Stream<Map<String, Object>>) getW3CMethod.invoke(srcPayload))
.findFirst()
.map(json::write)
Expand Down Expand Up @@ -111,26 +111,31 @@ public Result createSession(HttpHandler client, Command command) throws IOExcept
public Either<SessionNotCreatedException, Result> createSession(
HttpHandler client, NewSessionPayload payload) throws IOException {
int threshold = (int) Math.min(Runtime.getRuntime().freeMemory() / 10, Integer.MAX_VALUE);
FileBackedOutputStream os = new FileBackedOutputStream(threshold);
FileBackedOutputStream os = new FileBackedOutputStream(threshold, true);

try (CountingOutputStream counter = new CountingOutputStream(os);
Writer writer = new OutputStreamWriter(counter, UTF_8)) {
writeJsonPayload(payload, writer);

try (InputStream rawIn = os.asByteSource().openBufferedStream();
BufferedInputStream contentStream = new BufferedInputStream(rawIn)) {
Method createSessionMethod = ProtocolHandshake.class.getDeclaredMethod("createSession",
HttpHandler.class, InputStream.class, long.class);
Supplier<InputStream> contentSupplier = () -> {
try {
return os.asByteSource().openBufferedStream();
} catch (IOException e) {
throw new RuntimeException(e);
}
};
try {
Method createSessionMethod = ProtocolHandshake.class.getDeclaredMethod(
"createSession", HttpHandler.class, Supplier.class, long.class
);
createSessionMethod.setAccessible(true);
//noinspection unchecked
return (Either<SessionNotCreatedException, Result>) createSessionMethod.invoke(
this, client, contentStream, counter.getCount()
this, client, contentSupplier, counter.getCount()
);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new WebDriverException(e);
}
} finally {
os.reset();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
import com.google.common.collect.ImmutableMap;
import io.appium.java_client.ExecutesMethod;
import org.openqa.selenium.DeviceRotation;
import org.openqa.selenium.Rotatable;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DriverCommand;
import org.openqa.selenium.remote.Response;

import java.util.Map;

public interface SupportsRotation extends WebDriver, ExecutesMethod, Rotatable {
public interface SupportsRotation extends WebDriver, ExecutesMethod {
/**
* Get device rotation.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ContextAware;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.DeviceRotation;
import org.openqa.selenium.HasCapabilities;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.Rotatable;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
Expand All @@ -43,7 +40,7 @@
import java.util.Map;
import java.util.Set;

public class EmptyWebDriver implements WebDriver, ContextAware, Rotatable,
public class EmptyWebDriver implements WebDriver, ContextAware,
JavascriptExecutor, HasCapabilities, TakesScreenshot {
public EmptyWebDriver() {
}
Expand All @@ -64,20 +61,6 @@ public String getContext() {
return "";
}

public void rotate(ScreenOrientation orientation) {
}

public void rotate(DeviceRotation rotation) {
}

public ScreenOrientation getOrientation() {
return null;
}

public DeviceRotation rotation() {
return null;
}

public void get(String url) {
}

Expand Down