Search in sources :

Example 1 with InternetExplorerDriverService

use of org.openqa.selenium.ie.InternetExplorerDriverService in project jmeter-plugins by undera.

the class InternetExplorerDriverConfigTest method shouldQuitWebDriverAndStopServiceWhenQuitBrowserIsInvoked.

@Test
public void shouldQuitWebDriverAndStopServiceWhenQuitBrowserIsInvoked() throws Exception {
    InternetExplorerDriver mockInternetExplorerDriver = mock(InternetExplorerDriver.class);
    InternetExplorerDriverService mockService = mock(InternetExplorerDriverService.class);
    when(mockService.isRunning()).thenReturn(true);
    config.getServices().put(config.currentThreadName(), mockService);
    config.quitBrowser(mockInternetExplorerDriver);
    verify(mockInternetExplorerDriver).quit();
    assertThat(config.getServices(), is(Collections.<String, InternetExplorerDriverService>emptyMap()));
    verify(mockService, times(1)).stop();
}
Also used : InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) InternetExplorerDriverService(org.openqa.selenium.ie.InternetExplorerDriverService) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with InternetExplorerDriverService

use of org.openqa.selenium.ie.InternetExplorerDriverService in project jmeter-plugins by undera.

the class InternetExplorerDriverConfig method quitBrowser.

@Override
public void quitBrowser(final InternetExplorerDriver browser) {
    super.quitBrowser(browser);
    final InternetExplorerDriverService service = services.remove(currentThreadName());
    if (service != null && service.isRunning()) {
        service.stop();
    }
}
Also used : InternetExplorerDriverService(org.openqa.selenium.ie.InternetExplorerDriverService)

Example 3 with InternetExplorerDriverService

use of org.openqa.selenium.ie.InternetExplorerDriverService in project jmeter-plugins by undera.

the class InternetExplorerDriverConfig method getThreadService.

private InternetExplorerDriverService getThreadService() {
    InternetExplorerDriverService service = services.get(currentThreadName());
    if (service != null) {
        return service;
    }
    try {
        service = new InternetExplorerDriverService.Builder().usingDriverExecutable(new File(getInternetExplorerDriverPath())).build();
        service.start();
        services.put(currentThreadName(), service);
    } catch (IOException e) {
        LOGGER.error("Failed to start chrome service");
        service = null;
    }
    return service;
}
Also used : InternetExplorerDriverService(org.openqa.selenium.ie.InternetExplorerDriverService) IOException(java.io.IOException) File(java.io.File)

Example 4 with InternetExplorerDriverService

use of org.openqa.selenium.ie.InternetExplorerDriverService in project jmeter-plugins by undera.

the class InternetExplorerDriverConfigTest method shouldCreateInternetExplorerAndStartService.

@Test
public void shouldCreateInternetExplorerAndStartService() throws Exception {
    InternetExplorerDriver mockInternetExplorerDriver = mock(InternetExplorerDriver.class);
    whenNew(InternetExplorerDriver.class).withParameterTypes(InternetExplorerDriverService.class, Capabilities.class).withArguments(isA(InternetExplorerDriverService.class), isA(Capabilities.class)).thenReturn(mockInternetExplorerDriver);
    InternetExplorerDriverService.Builder mockServiceBuilder = mock(InternetExplorerDriverService.Builder.class);
    whenNew(InternetExplorerDriverService.Builder.class).withNoArguments().thenReturn(mockServiceBuilder);
    when(mockServiceBuilder.usingDriverExecutable(isA(File.class))).thenReturn(mockServiceBuilder);
    InternetExplorerDriverService mockService = mock(InternetExplorerDriverService.class);
    when(mockServiceBuilder.build()).thenReturn(mockService);
    final InternetExplorerDriver browser = config.createBrowser();
    assertThat(browser, is(mockInternetExplorerDriver));
    verifyNew(InternetExplorerDriver.class, times(1)).withArguments(isA(InternetExplorerDriverService.class), isA(Capabilities.class));
    verify(mockServiceBuilder, times(1)).build();
    assertThat(config.getServices().size(), is(1));
    assertThat(config.getServices().values(), hasItem(mockService));
}
Also used : InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) Capabilities(org.openqa.selenium.Capabilities) InternetExplorerDriverService(org.openqa.selenium.ie.InternetExplorerDriverService) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with InternetExplorerDriverService

use of org.openqa.selenium.ie.InternetExplorerDriverService in project jmeter-plugins by undera.

the class InternetExplorerDriverConfigTest method shouldBeAbleToCallQuitBrowserMultipleTimes.

@Test
public void shouldBeAbleToCallQuitBrowserMultipleTimes() throws Exception {
    InternetExplorerDriver mockInternetExplorerDriver = mock(InternetExplorerDriver.class);
    InternetExplorerDriverService mockService = mock(InternetExplorerDriverService.class);
    when(mockService.isRunning()).thenReturn(true);
    config.getServices().put(config.currentThreadName(), mockService);
    config.quitBrowser(mockInternetExplorerDriver);
    config.quitBrowser(mockInternetExplorerDriver);
    assertThat(config.getServices(), is(Collections.<String, InternetExplorerDriverService>emptyMap()));
    verify(mockService, times(1)).stop();
}
Also used : InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) InternetExplorerDriverService(org.openqa.selenium.ie.InternetExplorerDriverService) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

InternetExplorerDriverService (org.openqa.selenium.ie.InternetExplorerDriverService)8 InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)6 Test (org.junit.Test)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 File (java.io.File)1 IOException (java.io.IOException)1 Capabilities (org.openqa.selenium.Capabilities)1 InternetExplorerOptions (org.openqa.selenium.ie.InternetExplorerOptions)1