Skip to content

Commit

Permalink
Coerce a "proxy" capability to a proxy object
Browse files Browse the repository at this point in the history
We lost this when proxy serialized itself cleanly.
Hacking it back in so that we can get a 3.4 release
out the door.
  • Loading branch information
shs96c committed Apr 18, 2017
1 parent 2dce963 commit 787d4ed
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.google.gson.stream.JsonWriter;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.SessionNotCreatedException;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpMethod;
Expand Down Expand Up @@ -377,14 +378,24 @@ private Optional<Result> createSession(HttpClient client, InputStream newSession
}

if (value != null && value instanceof Map) {
capabilities = (Map<String, ?>) value;
capabilities = (Map<String, Object>) value;
} else if (value != null && value instanceof Capabilities) {
capabilities = ((Capabilities) capabilities).asMap();
}

// If the result looks positive, return the result.
if (sessionId != null && capabilities != null) {
Dialect dialect = ossStatus == null ? Dialect.W3C : Dialect.OSS;

// Massage the Proxy if it's here.
Object existingProxy = capabilities.get(CapabilityType.PROXY);
if (existingProxy instanceof Map) {
// Forget you, java generics. Forget you.
((Map<String, Object>)capabilities).put(
CapabilityType.PROXY,
new Proxy((Map<String, ?>) existingProxy));
}

return Optional.of(new Result(dialect, String.valueOf(sessionId), capabilities));
}

Expand Down

0 comments on commit 787d4ed

Please sign in to comment.