Search in sources :

Example 21 with WebUIDriver

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());
}
Also used : WebUIDriver(com.seleniumtests.driver.WebUIDriver) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 22 with WebUIDriver

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());
}
Also used : WebUIDriver(com.seleniumtests.driver.WebUIDriver) WebDriverException(org.openqa.selenium.WebDriverException) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 23 with WebUIDriver

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());
}
Also used : NLWebDriver(com.neotys.selenium.proxies.NLWebDriver) WebDriver(org.openqa.selenium.WebDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) WebUIDriver(com.seleniumtests.driver.WebUIDriver) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 24 with WebUIDriver

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());
}
Also used : WebUIDriver(com.seleniumtests.driver.WebUIDriver) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 25 with WebUIDriver

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());
}
Also used : WebUIDriver(com.seleniumtests.driver.WebUIDriver) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

WebUIDriver (com.seleniumtests.driver.WebUIDriver)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)19 Test (org.testng.annotations.Test)19 GenericTest (com.seleniumtests.GenericTest)14 MockitoTest (com.seleniumtests.MockitoTest)14 ConnectorsTest (com.seleniumtests.ConnectorsTest)5 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)5 ReporterTest (com.seleniumtests.it.reporter.ReporterTest)5 NLWebDriver (com.neotys.selenium.proxies.NLWebDriver)2 ScenarioException (com.seleniumtests.customexception.ScenarioException)2 VideoRecorder (com.seleniumtests.util.video.VideoRecorder)2 File (java.io.File)2 Dimension (org.openqa.selenium.Dimension)2 WebDriver (org.openqa.selenium.WebDriver)2 Point (org.openqa.selenium.Point)1 WebDriverException (org.openqa.selenium.WebDriverException)1 Actions (org.openqa.selenium.interactions.Actions)1 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)1 SessionId (org.openqa.selenium.remote.SessionId)1