use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testDriverCreationWithVideo.
@Test(groups = { "ut" })
public void testDriverCreationWithVideo() throws Exception {
SeleniumTestsContextManager.getThreadContext().setVideoCapture("true");
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
PowerMockito.mockStatic(CustomEventFiringWebDriver.class);
PowerMockito.doReturn(videoRecorder).when(CustomEventFiringWebDriver.class, "startVideoCapture", eq(DriverMode.LOCAL), eq(null), any(File.class), eq("videoCapture.avi"));
WebDriver driver = WebUIDriver.getWebDriver(true);
Assert.assertTrue(driver instanceof CustomEventFiringWebDriver);
Assert.assertNotNull(WebUIDriver.getVideoRecorder().get());
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testDriverCreationInGrid.
/**
* issue #280: check that selectedBrowserInfo is available in grid mode
* @throws Exception
*/
@Test(groups = { "ut" })
public void testDriverCreationInGrid() throws Exception {
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
SeleniumTestsContextManager.getThreadContext().setWebDriverGrid("http://localhost:4444/wd/hub");
SeleniumTestsContextManager.getThreadContext().setRunMode("grid");
// set connector to simulate the driver creation on grid
SeleniumTestsContextManager.getThreadContext().setSeleniumGridConnectors(Arrays.asList(gridConnector));
when(gridConnector.getNodeUrl()).thenReturn("http://localhost:5555/");
whenNew(SeleniumGridDriverFactory.class).withAnyArguments().thenReturn(gridDriverFactory);
when(gridDriverFactory.createWebDriver()).thenReturn(drv1);
when(gridDriverFactory.getSelectedBrowserInfo()).thenReturn(new BrowserInfo(BrowserType.HTMLUNIT, "1.1"));
CustomEventFiringWebDriver ceDriver = (CustomEventFiringWebDriver) WebUIDriver.getWebDriver(true);
Assert.assertNotNull(ceDriver.getBrowserInfo());
Assert.assertEquals(ceDriver.getBrowserInfo().getVersion(), "1.1");
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testCapsOnDriverQuit.
/**
* Check that usage duration is added on driver quit
*/
@Test(groups = { "ut" })
public void testCapsOnDriverQuit() {
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
CustomEventFiringWebDriver driver = (CustomEventFiringWebDriver) WebUIDriver.getWebDriver(true);
driver.quit();
List<DriverUsage> driverUsages = StatisticsStorage.getDriverUsage();
Assert.assertEquals(driverUsages.size(), 1);
Assert.assertEquals(driverUsages.get(0).getBrowserName(), "htmlunit");
Assert.assertTrue(driverUsages.get(0).getDuration() > 0.0);
Assert.assertNull(driverUsages.get(0).getGridHub());
Assert.assertNull(driverUsages.get(0).getGridNode());
Assert.assertTrue(driverUsages.get(0).getStartTime() > 0);
Assert.assertEquals(driverUsages.get(0).getTestName(), "testCapsOnDriverQuit");
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestFrameElement method init.
@BeforeMethod(groups = { "ut" })
private void init() {
SeleniumTestsContextManager.getThreadContext().setBrowser("firefox");
eventDriver = spy(new CustomEventFiringWebDriver(driver));
PowerMockito.mockStatic(WebUIDriver.class);
when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(eventDriver);
when(driver.findElement(By.id("el"))).thenReturn(element);
when(element.findElement(By.id("link"))).thenReturn(link);
when(element.findElements(By.tagName("tr"))).thenReturn(Arrays.asList(row));
when(row.findElements(any(By.class))).thenReturn(Arrays.asList(cell));
when(driver.findElements(By.id("frameId"))).thenReturn(Arrays.asList(frameEl));
when(driver.findElements(By.id("frameId2"))).thenReturn(Arrays.asList(subFrameEl));
when(driver.findElements(By.tagName("iframe"))).thenReturn(Arrays.asList(frameEl));
when(driver.findElements(By.tagName("iframe"))).thenReturn(Arrays.asList(frameEl, frameEl2));
when(driver.switchTo()).thenReturn(locator);
doNothing().when(eventDriver).scrollToElement(any(WebElement.class), anyInt());
when(frameEl.getText()).thenReturn("111");
when(frameEl2.getText()).thenReturn("222");
when(element.getSize()).thenReturn(new Dimension(1, 1));
when(element.isDisplayed()).thenReturn(true);
when(link.isDisplayed()).thenReturn(true);
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestHtmlElement method testPinch.
@Test(groups = { "ut" })
public void testPinch() throws Exception {
SeleniumTestsContextManager.getThreadContext().setTestType(TestType.APPIUM_WEB_ANDROID);
SeleniumTestsContextManager.getThreadContext().setPlatform("android");
when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(new CustomEventFiringWebDriver(mobileDriver));
doNothing().when(el).findElement(anyBoolean(), anyBoolean());
el.setElement(mobileElement);
el.pinch();
PowerMockito.verifyPrivate(el, atLeastOnce()).invoke("checkForMobile");
}
Aggregations