use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class Table method getCell.
/**
* Get a table cell at row,column coordinates
*
* Tip: returned element is a HtmlElement, but you must cast it to use its specific methods
*
* @param row the row index
* @param column the column index
* @param focus if true, scroll to this cell
* @return
*/
public WebElement getCell(final int row, final int column, boolean focus) {
WebElement cell = getCell(row, column);
if (focus) {
Point loc = cell.getLocation();
((CustomEventFiringWebDriver) getDriver()).scrollTo(loc.x - 50, loc.y - 50);
}
return cell;
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestBrowserSnapshot method testSnapshotWithJavascriptErrors.
/**
* issue #272: Test taking snapshot inside an iframe when some javascript error occurs. This happens with some website where access to iframe seems denied
* We want to get source and title, even if picture is not get
* @throws Exception
*/
@Test(groups = { "it" })
public void testSnapshotWithJavascriptErrors() throws Exception {
driver.switchTo().frame(DriverTestPage.iframe.getElement());
// get real capture
generateCaptureFilePath();
CustomEventFiringWebDriver mockedDriver = (CustomEventFiringWebDriver) spy(driver);
ScreenshotUtil screenshotUtil = spy(new ScreenshotUtil(mockedDriver));
doThrow(JavascriptException.class).when(mockedDriver).scrollTop();
doThrow(JavascriptException.class).when(mockedDriver).scrollTo(anyInt(), anyInt());
ScreenShot screenshot = screenshotUtil.capture(SnapshotTarget.PAGE, ScreenShot.class);
Assert.assertNotNull(screenshot.getHtmlSourcePath());
Assert.assertNotNull(screenshot.getFullImagePath());
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestCustomEventFiringWebDriver method testEdgeDriverClosed.
@Test(groups = { "it" })
public void testEdgeDriverClosed() {
if (!installedBrowsers.contains(BrowserType.EDGE)) {
throw new SkipException("browser not found");
}
WebDriver driver = WebUIDriver.getWebDriver(true, BrowserType.EDGE, "main", null);
try {
Assert.assertFalse(((CustomEventFiringWebDriver) driver).isBrowserClosed());
driver.close();
Assert.assertTrue(((CustomEventFiringWebDriver) driver).isBrowserClosed());
} finally {
driver.quit();
}
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestCustomEventFiringWebDriver method testIEDriverClosed.
@Test(groups = { "it" })
public void testIEDriverClosed() {
if (!installedBrowsers.contains(BrowserType.INTERNET_EXPLORER)) {
throw new SkipException("browser not found");
}
WebDriver driver = WebUIDriver.getWebDriver(true, BrowserType.INTERNET_EXPLORER, "main", null);
try {
Assert.assertFalse(((CustomEventFiringWebDriver) driver).isBrowserClosed());
driver.close();
Assert.assertTrue(((CustomEventFiringWebDriver) driver).isBrowserClosed());
} finally {
driver.quit();
}
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestBrowserSnapshot method testSnapshotWithErrors.
/**
* Test that if an unexpected error occurs when snapshot is taken, take desktop
* @throws Exception
*/
@Test(groups = { "it" })
public void testSnapshotWithErrors() throws Exception {
driver.switchTo().frame(DriverTestPage.iframe.getElement());
// get real capture
generateCaptureFilePath();
CustomEventFiringWebDriver mockedDriver = (CustomEventFiringWebDriver) spy(driver);
ScreenshotUtil screenshotUtil = spy(new ScreenshotUtil(mockedDriver));
doThrow(WebDriverException.class).when(mockedDriver).scrollTop();
doThrow(JavascriptException.class).when(mockedDriver).scrollTo(anyInt(), anyInt());
ScreenShot screenshot = screenshotUtil.capture(SnapshotTarget.PAGE, ScreenShot.class);
Assert.assertNotNull(screenshot.getHtmlSourcePath());
Assert.assertNotNull(screenshot.getFullImagePath());
}
Aggregations