Skip to content

Commit 3dbbc54

Browse files
committedApr 2, 2015
Chrome binary passed in capabilities has higher priority than node configuration
1 parent 2a60218 commit 3dbbc54

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed
 

‎java/server/src/org/openqa/grid/selenium/proxy/DefaultRemoteProxy.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ public void beforeSession(TestSession session) {
238238
if (options == null) {
239239
options = new HashMap<String, Object>();
240240
}
241-
options.put("binary", session.getSlot().getCapabilities().get("chrome_binary"));
241+
if (!options.containsKey("binary")) {
242+
options.put("binary", session.getSlot().getCapabilities().get("chrome_binary"));
243+
}
242244
cap.put(ChromeOptions.CAPABILITY, options);
243245
}
244246
}

‎java/server/test/org/openqa/grid/e2e/node/DefaultProxyFindsFirefoxLocationsTest.java

+18-21
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import static org.junit.Assert.assertEquals;
2121
import static org.mockito.Mockito.mock;
2222

23-
import com.google.gson.JsonObject;
24-
2523
import org.junit.AfterClass;
2624
import org.junit.BeforeClass;
2725
import org.junit.Test;
@@ -152,61 +150,60 @@ public void testBrowserLocations() throws MalformedURLException {
152150
newSessionRequest = new MockedRequestHandler(getNewRequest(req_caps));
153151
newSessionRequest.process();
154152

155-
JsonObject json = (JsonObject) newSessionRequest.getSession().getRequestedCapabilities().get(ChromeOptions.CAPABILITY);
156-
assertEquals(locationChrome27, json.get("binary").getAsString());
153+
Map<String, Object> json = (Map<String, Object>) newSessionRequest.getSession().getRequestedCapabilities().get(ChromeOptions.CAPABILITY);
154+
assertEquals(locationChrome27, json.get("binary"));
157155

158156
req_caps = new HashMap<String, Object>();
159157
req_caps.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
160158
req_caps.put(CapabilityType.VERSION, "29");
161159
newSessionRequest = new MockedRequestHandler(getNewRequest(req_caps));
162160
newSessionRequest.process();
163161

164-
json = (JsonObject) newSessionRequest.getSession().getRequestedCapabilities().get(ChromeOptions.CAPABILITY);
165-
assertEquals(locationChrome29, json.get("binary").getAsString());
162+
json = (Map<String, Object>) newSessionRequest.getSession().getRequestedCapabilities().get(ChromeOptions.CAPABILITY);
163+
assertEquals(locationChrome29, json.get("binary"));
166164

167165
req_caps = new HashMap<String, Object>();
168166
req_caps.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
169167
req_caps.put(CapabilityType.VERSION, "29");
170-
JsonObject options = new JsonObject();
171-
options.addProperty("test1", "test2");
168+
Map<String, Object> options = new HashMap<String, Object>();
169+
options.put("test1", "test2");
172170
req_caps.put(ChromeOptions.CAPABILITY, options);
173171
newSessionRequest = new MockedRequestHandler(getNewRequest(req_caps));
174172
newSessionRequest.process();
175173

176-
json = (JsonObject) newSessionRequest.getSession().getRequestedCapabilities().get(ChromeOptions.CAPABILITY);
177-
assertEquals(locationChrome29, json.get("binary").getAsString());
178-
assertEquals("test2", json.get("test1").getAsString());
174+
json = (Map<String, Object>) newSessionRequest.getSession().getRequestedCapabilities().get(ChromeOptions.CAPABILITY);
175+
assertEquals(locationChrome29, json.get("binary"));
176+
assertEquals("test2", json.get("test1"));
179177

180178
req_caps = new HashMap<String, Object>();
181179
req_caps.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
182180
req_caps.put(CapabilityType.VERSION, "30");
183-
options = new JsonObject();
184-
options.addProperty("test11", "test22");
185-
options.addProperty("binary", "custom");
181+
options = new HashMap<String, Object>();
182+
options.put("test11", "test22");
183+
options.put("binary", "custom");
186184
req_caps.put(ChromeOptions.CAPABILITY, options);
187185
newSessionRequest = new MockedRequestHandler(getNewRequest(req_caps));
188186
newSessionRequest.process();
189187

190-
json = (JsonObject) newSessionRequest.getSession().getRequestedCapabilities().get(ChromeOptions.CAPABILITY);
191-
// Ignored due it fails
192-
//Assert.assertEquals("custom", json.get("binary").getAsString());
193-
assertEquals("test22", json.get("test11").getAsString());
188+
json = (Map<String, Object>) newSessionRequest.getSession().getRequestedCapabilities().get(ChromeOptions.CAPABILITY);
189+
assertEquals("custom", json.get("binary"));
190+
assertEquals("test22", json.get("test11"));
194191
}
195192

196193
@AfterClass
197194
public static void teardown() throws Exception {
198195
remote.stopRemoteServer();
199196
hub.stop();
200197
}
201-
198+
202199
private SeleniumBasedRequest getNewRequest(Map<String, Object> desiredCapability) {
203200
HttpServletRequest httpreq = mock(HttpServletRequest.class);
204201
return new SeleniumBasedRequest(httpreq, registry, RequestType.START_SESSION, desiredCapability) {
205202

206203
public String getNewSessionRequestedCapability(TestSession session) {
207204
return null;
208205
}
209-
206+
210207
public ExternalSessionKey extractSession() {
211208
return null;
212209
}
@@ -239,4 +236,4 @@ public void forwardNewSessionRequestAndUpdateRegistry(TestSession session)
239236
throws NewSessionException {}
240237
}
241238

242-
}
239+
}

0 commit comments

Comments
 (0)