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());
}
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());
}
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());
}
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;
}
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;
}
Aggregations