Search in sources :

Example 51 with CustomEventFiringWebDriver

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;
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Point(org.openqa.selenium.Point) WebElement(org.openqa.selenium.WebElement)

Example 52 with CustomEventFiringWebDriver

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());
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) ScreenshotUtil(com.seleniumtests.driver.screenshots.ScreenshotUtil) Test(org.testng.annotations.Test) GenericMultiBrowserTest(com.seleniumtests.it.driver.support.GenericMultiBrowserTest)

Example 53 with CustomEventFiringWebDriver

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();
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) SkipException(org.testng.SkipException) GenericDriverTest(com.seleniumtests.GenericDriverTest) Test(org.testng.annotations.Test)

Example 54 with CustomEventFiringWebDriver

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();
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) SkipException(org.testng.SkipException) GenericDriverTest(com.seleniumtests.GenericDriverTest) Test(org.testng.annotations.Test)

Example 55 with CustomEventFiringWebDriver

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());
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) ScreenshotUtil(com.seleniumtests.driver.screenshots.ScreenshotUtil) Test(org.testng.annotations.Test) GenericMultiBrowserTest(com.seleniumtests.it.driver.support.GenericMultiBrowserTest)

Aggregations

CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)77 Test (org.testng.annotations.Test)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)36 MockitoTest (com.seleniumtests.MockitoTest)35 Dimension (org.openqa.selenium.Dimension)26 WebDriver (org.openqa.selenium.WebDriver)14 GenericDriverTest (com.seleniumtests.GenericDriverTest)12 Point (org.openqa.selenium.Point)12 GenericTest (com.seleniumtests.GenericTest)10 ScenarioException (com.seleniumtests.customexception.ScenarioException)9 WebDriverException (org.openqa.selenium.WebDriverException)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 DriverExceptionListener (com.seleniumtests.driver.DriverExceptionListener)6 SkipException (org.testng.SkipException)6 NLWebDriver (com.neotys.selenium.proxies.NLWebDriver)5 File (java.io.File)5 IOException (java.io.IOException)5 Rectangle (org.openqa.selenium.Rectangle)5 WebElement (org.openqa.selenium.WebElement)5 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)4