IECapabilityProcessor implements CapabilityProcessor { @Override public void process(JsonCapabilities caps) { caps.any().put("ie.ensureCleanSession", true); caps.any().put("ie.usePerProcessProxy", true); if (!caps.any().containsKey("proxy")) { Proxy proxy = new Proxy(); proxy.setProxyType("DIRECT"); caps.any().put("proxy", proxy); } }  @Override boolean accept(JsonCapabilities caps); @Override void process(JsonCapabilities caps);  }
@Test public void testAddProxy() throws Exception { String version = "11"; JsonCapabilities capabilities = buildJsonCapabilities(internetExplorer(), version); processor.process(capabilities); assertThat(capabilities.getBrowserName(), is(equalTo(IE))); assertThat(capabilities.getVersion(), is(equalTo(version))); assertThat(capabilities.any().get(PROXY), is(notNullValue())); assertThat(((Proxy) capabilities.any().get(PROXY)).getProxyType(), is(equalTo(DIRECT.name()))); }
@Test public void testJsonMarshalling() throws Exception { JsonMessage message = buildJsonMessage(internetExplorer()); processor.process(message.getDesiredCapabilities()); String proxyType = (String) new JSONObject(message.toJson()) .getJSONObject("desiredCapabilities") .getJSONObject("proxy") .get("proxyType"); assertThat(proxyType, is(equalTo(DIRECT.name()))); }
@Test public void testExistingProxyIsNotOverridden() throws Exception { DesiredCapabilities caps = internetExplorer(); org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy(); proxy.setHttpProxy(PROXY); caps.setCapability(PROXY, proxy); JsonCapabilities capabilities = buildJsonCapabilities(caps); processor.process(capabilities); assertThat(capabilities.any().get(PROXY), not(instanceOf(Proxy.class))); }