use of org.openqa.selenium.chrome.ChromeDriverService in project camunda-bpm-platform by camunda.
the class AbstractWebappUiIntegrationTest method createDriver.
@BeforeClass
public static void createDriver() {
String chromeDriverExecutable = "chromedriver";
if (System.getProperty("os.name").toLowerCase(Locale.US).indexOf("windows") > -1) {
chromeDriverExecutable += ".exe";
}
File chromeDriver = new File("target/chromedriver/" + chromeDriverExecutable);
if (!chromeDriver.exists()) {
throw new RuntimeException("chromedriver could not be located!");
}
ChromeDriverService chromeDriverService = new ChromeDriverService.Builder().withVerbose(true).usingAnyFreePort().usingDriverExecutable(chromeDriver).build();
driver = new ChromeDriver(chromeDriverService);
}
use of org.openqa.selenium.chrome.ChromeDriverService in project jmeter-plugins by undera.
the class ChromeDriverConfig method getThreadService.
private ChromeDriverService getThreadService() {
ChromeDriverService service = services.get(currentThreadName());
if (service != null) {
return service;
}
try {
service = new ChromeDriverService.Builder().usingDriverExecutable(new File(getChromeDriverPath())).build();
service.start();
services.put(currentThreadName(), service);
} catch (IOException e) {
LOGGER.error("Failed to start chrome service");
service = null;
}
return service;
}
use of org.openqa.selenium.chrome.ChromeDriverService in project jmeter-plugins by undera.
the class ChromeDriverConfigTest method shouldQuitWebDriverAndStopServiceWhenQuitBrowserIsInvoked.
@Test
public void shouldQuitWebDriverAndStopServiceWhenQuitBrowserIsInvoked() throws Exception {
ChromeDriver mockChromeDriver = mock(ChromeDriver.class);
ChromeDriverService mockService = mock(ChromeDriverService.class);
when(mockService.isRunning()).thenReturn(true);
config.getServices().put(config.currentThreadName(), mockService);
config.quitBrowser(mockChromeDriver);
verify(mockChromeDriver).quit();
assertThat(config.getServices(), is(Collections.<String, ChromeDriverService>emptyMap()));
verify(mockService, times(1)).stop();
}
use of org.openqa.selenium.chrome.ChromeDriverService in project jmeter-plugins by undera.
the class ChromeDriverConfigTest method shouldCreateChromeAndStartService.
@Test
public void shouldCreateChromeAndStartService() throws Exception {
ChromeDriver mockChromeDriver = mock(ChromeDriver.class);
whenNew(ChromeDriver.class).withParameterTypes(ChromeDriverService.class, Capabilities.class).withArguments(isA(ChromeDriverService.class), isA(Capabilities.class)).thenReturn(mockChromeDriver);
ChromeDriverService.Builder mockServiceBuilder = mock(ChromeDriverService.Builder.class);
whenNew(ChromeDriverService.Builder.class).withNoArguments().thenReturn(mockServiceBuilder);
when(mockServiceBuilder.usingDriverExecutable(isA(File.class))).thenReturn(mockServiceBuilder);
ChromeDriverService mockService = mock(ChromeDriverService.class);
when(mockServiceBuilder.build()).thenReturn(mockService);
final ChromeDriver browser = config.createBrowser();
assertThat(browser, is(mockChromeDriver));
verifyNew(ChromeDriver.class, times(1)).withArguments(isA(ChromeDriverService.class), isA(Capabilities.class));
verify(mockServiceBuilder, times(1)).build();
assertThat(config.getServices().size(), is(1));
assertThat(config.getServices().values(), hasItem(mockService));
}
use of org.openqa.selenium.chrome.ChromeDriverService in project jmeter-plugins by undera.
the class ChromeDriverConfigTest method shouldNotCreateChromeWhenStartingServiceThrowsAnException.
@Test
public void shouldNotCreateChromeWhenStartingServiceThrowsAnException() throws Exception {
ChromeDriverService.Builder mockServiceBuilder = mock(ChromeDriverService.Builder.class);
whenNew(ChromeDriverService.Builder.class).withNoArguments().thenReturn(mockServiceBuilder);
when(mockServiceBuilder.usingDriverExecutable(isA(File.class))).thenReturn(mockServiceBuilder);
ChromeDriverService mockService = mock(ChromeDriverService.class);
when(mockServiceBuilder.build()).thenReturn(mockService);
doThrow(new IOException("Stubbed exception")).when(mockService).start();
final ChromeDriver browser = config.createBrowser();
assertThat(browser, is(nullValue()));
assertThat(config.getServices(), is(Collections.<String, ChromeDriverService>emptyMap()));
verify(mockServiceBuilder, times(1)).build();
}
Aggregations