|
30 | 30 | import org.openqa.grid.internal.listeners.TestSessionListener;
|
31 | 31 | import org.openqa.grid.internal.listeners.TimeoutListener;
|
32 | 32 | import org.openqa.grid.internal.utils.HtmlRenderer;
|
| 33 | +import org.openqa.grid.selenium.node.ChromeMutator; |
33 | 34 | import org.openqa.grid.selenium.node.FirefoxMutator;
|
34 |
| -import org.openqa.selenium.chrome.ChromeOptions; |
35 |
| -import org.openqa.selenium.firefox.FirefoxDriver; |
36 |
| -import org.openqa.selenium.firefox.FirefoxOptions; |
37 |
| -import org.openqa.selenium.remote.BrowserType; |
38 |
| -import org.openqa.selenium.remote.CapabilityType; |
| 35 | +import org.openqa.selenium.ImmutableCapabilities; |
39 | 36 |
|
40 |
| -import java.util.HashMap; |
41 | 37 | import java.util.List;
|
42 | 38 | import java.util.Map;
|
43 | 39 | import java.util.concurrent.CopyOnWriteArrayList;
|
@@ -224,35 +220,12 @@ public void beforeSession(TestSession session) {
|
224 | 220 | if (session.getSlot().getProtocol() == SeleniumProtocol.WebDriver) {
|
225 | 221 | Map<String, Object> cap = session.getRequestedCapabilities();
|
226 | 222 |
|
227 |
| - if (BrowserType.FIREFOX.equals(cap.get(CapabilityType.BROWSER_NAME)) && |
228 |
| - session.getSlot().getCapabilities().get(FirefoxDriver.BINARY) != null) { |
229 |
| - String binary = (String) session.getSlot().getCapabilities().get(FirefoxDriver.BINARY); |
| 223 | + ImmutableCapabilities caps = new ImmutableCapabilities(cap); |
| 224 | + caps = new ChromeMutator(session.getSlot().getCapabilities()).apply(caps); |
| 225 | + caps = new FirefoxMutator(session.getSlot().getCapabilities()).apply(caps); |
230 | 226 |
|
231 |
| - if (cap.get(FirefoxDriver.BINARY) == null) { |
232 |
| - session.getRequestedCapabilities().put(FirefoxDriver.BINARY, binary); |
233 |
| - } |
234 |
| - |
235 |
| - if (cap.get(FirefoxOptions.FIREFOX_OPTIONS) instanceof Map) { |
236 |
| - @SuppressWarnings("unchecked") Map<String, Object> options = |
237 |
| - (Map<String, Object>) cap.get(FirefoxOptions.FIREFOX_OPTIONS); |
238 |
| - if (options.get("binary") == null) { |
239 |
| - options.put("binary", session.getSlot().getCapabilities().get(FirefoxDriver.BINARY)); |
240 |
| - } |
241 |
| - } |
242 |
| - } |
243 |
| - |
244 |
| - if (BrowserType.CHROME.equals(cap.get(CapabilityType.BROWSER_NAME))) { |
245 |
| - if (session.getSlot().getCapabilities().get("chrome_binary") != null) { |
246 |
| - Map<String, Object> options = (Map<String, Object>) cap.get(ChromeOptions.CAPABILITY); |
247 |
| - if (options == null) { |
248 |
| - options = new HashMap<>(); |
249 |
| - } |
250 |
| - if (!options.containsKey("binary")) { |
251 |
| - options.put("binary", session.getSlot().getCapabilities().get("chrome_binary")); |
252 |
| - } |
253 |
| - cap.put(ChromeOptions.CAPABILITY, options); |
254 |
| - } |
255 |
| - } |
| 227 | + cap.clear(); |
| 228 | + cap.putAll(caps.asMap()); |
256 | 229 | }
|
257 | 230 | }
|
258 | 231 |
|
|
0 commit comments