use of com.seleniumtests.driver.WebUIDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testCleanUp.
/**
* Check driver is quit
*/
@Test(groups = { "ut" })
public void testCleanUp() {
SeleniumTestsContextManager.getThreadContext().setCaptureNetwork(true);
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
WebUIDriver uiDriver = WebUIDriverFactory.getInstance("foo");
uiDriver.setDriver(eventDriver1);
WebUIDriver.cleanUp();
verify(eventDriver1).quit();
Assert.assertNull(uiDriver.getDriver());
}
use of com.seleniumtests.driver.WebUIDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testCleanUpWithError.
/**
* Check that test does not stop even if 'quit()' raises an error
*/
@Test(groups = { "ut" })
public void testCleanUpWithError() {
SeleniumTestsContextManager.getThreadContext().setCaptureNetwork(true);
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
WebUIDriver uiDriver = WebUIDriverFactory.getInstance("foo");
uiDriver.setDriver(eventDriver1);
doThrow(new WebDriverException("error")).when(eventDriver1).quit();
WebUIDriver.cleanUp();
verify(eventDriver1).quit();
Assert.assertNull(uiDriver.getDriver());
}
use of com.seleniumtests.driver.WebUIDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testNewDriverCreationInGrid.
/**
* Test that 2 drivers can be created specifying different name
*/
@Test(groups = { "ut" })
public void testNewDriverCreationInGrid() {
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
SeleniumTestsContextManager.getThreadContext().setWebDriverGrid("http://localhost:4444/wd/hub");
SeleniumTestsContextManager.getThreadContext().setRunMode("grid");
// create it so that we can control it via mock
WebUIDriver uiDriver1 = spy(WebUIDriver.getWebUIDriver(true, "main"));
WebUIDriver.getUxDriverSession().get().put("main", uiDriver1);
doReturn(drv1).when(uiDriver1).createWebDriver();
WebDriver driver1 = WebUIDriver.getWebDriver(true, BrowserType.HTMLUNIT, "main", null);
// set connector to simulate the driver creation on grid
SeleniumTestsContextManager.getThreadContext().setSeleniumGridConnector(gridConnector);
when(gridConnector.getNodeUrl()).thenReturn("http://localhost:5555/");
WebUIDriver uiDriver2 = spy(WebUIDriver.getWebUIDriver(true, "other"));
WebUIDriver.getUxDriverSession().get().put("other", uiDriver2);
doReturn(drv2).when(uiDriver2).createWebDriver();
WebDriver driver2 = WebUIDriver.getWebDriver(true, BrowserType.HTMLUNIT, "other", null);
Assert.assertNull(uiDriver1.getConfig().getRunOnSameNode());
Assert.assertNotNull(uiDriver2.getConfig().getRunOnSameNode());
}
use of com.seleniumtests.driver.WebUIDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testCleanUpWithBrowserMobInError.
/**
* Check no error is raised even if ending browsermob proxy raises an error
*/
@Test(groups = { "ut" })
public void testCleanUpWithBrowserMobInError() {
SeleniumTestsContextManager.getThreadContext().setCaptureNetwork(true);
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
WebUIDriver uiDriver = WebUIDriverFactory.getInstance("foo");
uiDriver.createRemoteWebDriver();
Assert.assertNotNull(uiDriver.getConfig().getBrowserMobProxy());
// raise an error ending
uiDriver.getConfig().setBrowserMobProxy(mobProxy);
doThrow(new NullPointerException("error")).when(mobProxy).endHar();
WebUIDriver.cleanUp();
Assert.assertNull(uiDriver.getConfig().getBrowserMobProxy());
}
use of com.seleniumtests.driver.WebUIDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testCleanUpMultipleBrowsers.
/**
* All drivers should be deleted
*/
@Test(groups = { "ut" })
public void testCleanUpMultipleBrowsers() {
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
WebUIDriver uiDriver1 = WebUIDriverFactory.getInstance("foo");
WebUIDriver uiDriver2 = WebUIDriverFactory.getInstance("bar");
uiDriver1.createRemoteWebDriver();
uiDriver2.createRemoteWebDriver();
Assert.assertEquals(WebUIDriver.getUxDriverSession().get().size(), 2);
WebUIDriver.cleanUp();
Assert.assertNull(uiDriver1.getDriver());
Assert.assertNull(uiDriver2.getDriver());
Assert.assertNull(WebUIDriver.getUxDriverSession().get());
}
Aggregations