Search in sources :

Example 1 with WebUIDriver

use of com.seleniumtests.driver.WebUIDriver in project seleniumRobot by bhecquet.

the class TestWebUIDriver method testCleanUpWithVideoCapture.

/**
 * video is closed when driver is cleaned
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testCleanUpWithVideoCapture() throws Exception {
    PowerMockito.mockStatic(CustomEventFiringWebDriver.class);
    PowerMockito.doReturn(videoRecorder).when(CustomEventFiringWebDriver.class, "startVideoCapture", eq(DriverMode.LOCAL), eq(null), any(File.class), eq("videoCapture.avi"));
    SeleniumTestsContextManager.getThreadContext().setVideoCapture("true");
    SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
    WebUIDriver uiDriver = WebUIDriverFactory.getInstance("foo");
    uiDriver.createRemoteWebDriver();
    VideoRecorder vRecorder = WebUIDriver.getVideoRecorder().get();
    Assert.assertNotNull(WebUIDriver.getVideoRecorder().get());
    WebUIDriver.cleanUp();
    PowerMockito.verifyStatic(CustomEventFiringWebDriver.class, times(1));
    CustomEventFiringWebDriver.stopVideoCapture(eq(DriverMode.LOCAL), eq(null), eq(vRecorder));
    Assert.assertNull(WebUIDriver.getVideoRecorder().get());
}
Also used : WebUIDriver(com.seleniumtests.driver.WebUIDriver) VideoRecorder(com.seleniumtests.util.video.VideoRecorder) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with WebUIDriver

use of com.seleniumtests.driver.WebUIDriver in project seleniumRobot by bhecquet.

the class TestWebUIDriver method testCleanUpWithVideoCaptureWithError.

/**
 * No error is raised when error happens closing video
 * videoRecorder is also removed
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testCleanUpWithVideoCaptureWithError() throws Exception {
    PowerMockito.mockStatic(CustomEventFiringWebDriver.class);
    PowerMockito.doReturn(videoRecorder).when(CustomEventFiringWebDriver.class, "startVideoCapture", eq(DriverMode.LOCAL), eq(null), any(File.class), eq("videoCapture.avi"));
    PowerMockito.doThrow(new NullPointerException("error")).when(CustomEventFiringWebDriver.class, "stopVideoCapture", eq(DriverMode.LOCAL), eq(null), any(VideoRecorder.class));
    SeleniumTestsContextManager.getThreadContext().setVideoCapture("true");
    SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
    WebUIDriver uiDriver = WebUIDriverFactory.getInstance("foo");
    uiDriver.createRemoteWebDriver();
    VideoRecorder vRecorder = WebUIDriver.getVideoRecorder().get();
    Assert.assertNotNull(WebUIDriver.getVideoRecorder().get());
    WebUIDriver.cleanUp();
    PowerMockito.verifyStatic(CustomEventFiringWebDriver.class, times(1));
    CustomEventFiringWebDriver.stopVideoCapture(eq(DriverMode.LOCAL), eq(null), eq(vRecorder));
    Assert.assertNull(WebUIDriver.getVideoRecorder().get());
}
Also used : WebUIDriver(com.seleniumtests.driver.WebUIDriver) VideoRecorder(com.seleniumtests.util.video.VideoRecorder) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with WebUIDriver

use of com.seleniumtests.driver.WebUIDriver in project seleniumRobot by bhecquet.

the class TestWebUIDriver method testDriverCreationWithBrowserMob.

@Test(groups = { "ut" })
public void testDriverCreationWithBrowserMob() {
    SeleniumTestsContextManager.getThreadContext().setCaptureNetwork(true);
    SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
    WebDriver driver = WebUIDriver.getWebDriver(true);
    Assert.assertTrue(driver instanceof CustomEventFiringWebDriver);
    WebUIDriver uiDriver = WebUIDriver.getWebUIDriver(false);
    Assert.assertNotNull(uiDriver.getConfig().getBrowserMobProxy());
}
Also used : NLWebDriver(com.neotys.selenium.proxies.NLWebDriver) WebDriver(org.openqa.selenium.WebDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) WebUIDriver(com.seleniumtests.driver.WebUIDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with WebUIDriver

use of com.seleniumtests.driver.WebUIDriver in project seleniumRobot by bhecquet.

the class PictureElement method isDriverCreated.

private WebUIDriver isDriverCreated() {
    WebUIDriver uiDriver = WebUIDriver.getWebUIDriver(false);
    if (uiDriver == null) {
        throw new ScenarioException("Driver has not already been created");
    }
    CustomEventFiringWebDriver driver = (CustomEventFiringWebDriver) uiDriver.getDriver();
    if (driver == null) {
        throw new ScenarioException("Driver has not already been created");
    }
    return uiDriver;
}
Also used : WebUIDriver(com.seleniumtests.driver.WebUIDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) ScenarioException(com.seleniumtests.customexception.ScenarioException)

Example 5 with WebUIDriver

use of com.seleniumtests.driver.WebUIDriver in project seleniumRobot by bhecquet.

the class PictureElement method doAfterPictureSearch.

protected void doAfterPictureSearch() {
    // scroll to element where our picture is so that we will be able to act on it
    // scrolling will display, on top of window, the top of the element
    intoElement.scrollToElement(0);
    WaitHelper.waitForMilliSeconds(500);
    WebUIDriver uiDriver = isDriverCreated();
    double pixelAspectRatio = ((CustomEventFiringWebDriver) uiDriver.getDriver()).getDeviceAspectRatio();
    // take into account the aspect ratio
    detectedObjectRectangle.x = (int) (detectedObjectRectangle.x / pixelAspectRatio);
    detectedObjectRectangle.y = (int) (detectedObjectRectangle.y / pixelAspectRatio);
    detectedObjectRectangle.width = (int) (detectedObjectRectangle.width / pixelAspectRatio);
    detectedObjectRectangle.height = (int) (detectedObjectRectangle.height / pixelAspectRatio);
    pictureSizeRatio = pictureSizeRatio / pixelAspectRatio;
}
Also used : WebUIDriver(com.seleniumtests.driver.WebUIDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver)

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