SeleniumEndpointComponent extends AbstractEndpointComponent { @Override protected Endpoint createEndpoint(String resourcePath, Map<String, String> parameters, TestContext context) { SeleniumBrowser browser = new SeleniumBrowser(); if (StringUtils.hasText(resourcePath) && !resourcePath.equals("browser")) { browser.getEndpointConfiguration().setBrowserType(resourcePath); } if (parameters.containsKey("start-page")) { browser.getEndpointConfiguration().setStartPageUrl(parameters.remove("start-page")); } if (parameters.containsKey("remote-server")) { browser.getEndpointConfiguration().setRemoteServerUrl(parameters.remove("remote-server")); } enrichEndpointConfiguration(browser.getEndpointConfiguration(), getEndpointConfigurationParameters(parameters, SeleniumBrowserConfiguration.class), context); return browser; } SeleniumEndpointComponent();   }
@Test public void testCreateBrowserEndpoint() throws Exception { SeleniumEndpointComponent component = new SeleniumEndpointComponent(); Endpoint endpoint = component.createEndpoint("selenium:browser", context); Assert.assertEquals(endpoint.getClass(), SeleniumBrowser.class); Assert.assertEquals(((SeleniumBrowser)endpoint).getEndpointConfiguration().getBrowserType(), BrowserType.HTMLUNIT); endpoint = component.createEndpoint("selenium:firefox", context); Assert.assertEquals(endpoint.getClass(), SeleniumBrowser.class); Assert.assertEquals(((SeleniumBrowser)endpoint).getEndpointConfiguration().getBrowserType(), BrowserType.FIREFOX); Assert.assertEquals(((SeleniumBrowser) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }
@Test public void testCreateBrowserEndpointWithParameters() throws Exception { SeleniumEndpointComponent component = new SeleniumEndpointComponent(); reset(referenceResolver); when(referenceResolver.isResolvable("chromeDriver")).thenReturn(true); when(referenceResolver.resolve("chromeDriver", WebDriver.class)).thenReturn(chromeDriver); Endpoint endpoint = component.createEndpoint("selenium:chrome?start-page=https: Assert.assertEquals(endpoint.getClass(), SeleniumBrowser.class); Assert.assertEquals(((SeleniumBrowser)endpoint).getEndpointConfiguration().getWebDriver(), chromeDriver); Assert.assertEquals(((SeleniumBrowser)endpoint).getEndpointConfiguration().getStartPageUrl(), "https: Assert.assertEquals(((SeleniumBrowser)endpoint).getEndpointConfiguration().getRemoteServerUrl(), "https: Assert.assertEquals(((SeleniumBrowser) endpoint).getEndpointConfiguration().getTimeout(), 10000L); }