23
23
import com .google .common .base .Preconditions ;
24
24
import com .google .common .base .StandardSystemProperty ;
25
25
26
+ import org .openqa .selenium .Capabilities ;
26
27
import org .openqa .selenium .ImmutableCapabilities ;
27
28
import org .openqa .selenium .SessionNotCreatedException ;
28
29
import org .openqa .selenium .WebDriver ;
29
30
import org .openqa .selenium .io .TemporaryFilesystem ;
30
31
import org .openqa .selenium .net .PortProber ;
31
32
import org .openqa .selenium .remote .Augmenter ;
33
+ import org .openqa .selenium .remote .Command ;
32
34
import org .openqa .selenium .remote .CommandCodec ;
33
35
import org .openqa .selenium .remote .CommandExecutor ;
34
36
import org .openqa .selenium .remote .Dialect ;
37
+ import org .openqa .selenium .remote .DriverCommand ;
35
38
import org .openqa .selenium .remote .ProtocolHandshake ;
36
39
import org .openqa .selenium .remote .RemoteWebDriver ;
37
40
import org .openqa .selenium .remote .Response ;
50
53
51
54
import java .io .File ;
52
55
import java .io .IOException ;
53
- import java .io .InputStream ;
54
56
import java .lang .reflect .Method ;
55
57
import java .net .URL ;
56
58
import java .util .Map ;
59
+ import java .util .Set ;
57
60
import java .util .function .Supplier ;
58
61
59
62
class ServicedSession implements ActiveSession {
@@ -169,10 +172,10 @@ public static class Factory implements SessionFactory {
169
172
}
170
173
171
174
@ Override
172
- public ActiveSession apply (NewSessionPayload payload ) {
175
+ public ActiveSession apply (Set < Dialect > downstreamDialects , Capabilities capabilities ) {
173
176
DriverService service = createService .get ();
174
177
175
- try ( InputStream in = payload . getPayload (). get ()) {
178
+ try {
176
179
service .start ();
177
180
178
181
PortProber .waitForPortUp (service .getUrl ().getPort (), 30 , SECONDS );
@@ -181,18 +184,18 @@ public ActiveSession apply(NewSessionPayload payload) {
181
184
182
185
HttpClient client = new ApacheHttpClient .Factory ().createClient (url );
183
186
184
- ProtocolHandshake . Result result = new ProtocolHandshake ()
185
- . createSession ( client , in , payload . getPayloadSize ())
186
- . orElseThrow (() -> new SessionNotCreatedException ( "Unable to create session" ) );
187
+ Command command = new Command ( null , DriverCommand . NEW_SESSION , capabilities . asMap ());
188
+
189
+ ProtocolHandshake . Result result = new ProtocolHandshake (). createSession ( client , command );
187
190
188
191
SessionCodec codec ;
189
192
Dialect upstream = result .getDialect ();
190
193
Dialect downstream ;
191
- if (payload . getDownstreamDialects () .contains (result .getDialect ())) {
194
+ if (downstreamDialects .contains (result .getDialect ())) {
192
195
codec = new Passthrough (url );
193
196
downstream = upstream ;
194
197
} else {
195
- downstream = payload . getDownstreamDialects () .iterator ().next ();
198
+ downstream = downstreamDialects .iterator ().next ();
196
199
197
200
codec = new ProtocolConverter (
198
201
url ,
0 commit comments