Search in sources :

Example 61 with CustomEventFiringWebDriver

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

the class TestCustomEventFiringWebDriver method testQuitInError.

/**
 * Check that even if error is raised when driver is quit, killing process is done
 */
@Test(groups = { "ut" })
public void testQuitInError() {
    when(browserInfo.getAllBrowserSubprocessPids(new ArrayList<>())).thenReturn(Arrays.asList(1000L));
    doThrow(new WebDriverException("some error")).when(driver).quit();
    try {
        ((CustomEventFiringWebDriver) eventDriver).quit();
    } catch (WebDriverException e) {
    }
    verify(osUtility).killProcess("1000", true);
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) WebDriverException(org.openqa.selenium.WebDriverException) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 62 with CustomEventFiringWebDriver

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

the class TestCustomEventFiringWebDriver method testContentDimensionNotGet2.

@Test(groups = { "ut" })
public void testContentDimensionNotGet2() {
    when(driver.executeScript(anyString(), eq(true))).thenReturn(Arrays.asList(0, 100)).thenReturn(Arrays.asList(120, 80));
    Dimension dim = ((CustomEventFiringWebDriver) eventDriver).getContentDimension();
    verify(driver).switchTo();
    // check we get the window dimension
    Assert.assertEquals(dim.height, 80);
    Assert.assertEquals(dim.width, 120);
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Dimension(org.openqa.selenium.Dimension) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 63 with CustomEventFiringWebDriver

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

the class TestCustomEventFiringWebDriver method testContentDimensionNotGet.

/**
 * issue #238: sometimes, when trying to capture screenshot, if browser context do not correspond to driver context
 * (we have switched to an iframe but never went back whereas displayed page is different), getContentDimension returns (0,0) which prevent screenshot from
 * being stored
 */
@Test(groups = { "ut" })
public void testContentDimensionNotGet() {
    when(driver.executeScript(anyString(), eq(true))).thenReturn(Arrays.asList(100, 0)).thenReturn(Arrays.asList(120, 80));
    Dimension dim = ((CustomEventFiringWebDriver) eventDriver).getContentDimension();
    verify(driver).switchTo();
    // check we get the window dimension
    Assert.assertEquals(dim.height, 80);
    Assert.assertEquals(dim.width, 120);
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Dimension(org.openqa.selenium.Dimension) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 64 with CustomEventFiringWebDriver

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

the class TestCustomEventFiringWebDriver method testScrollPositionWithZoomFactor.

/**
 * issue #165: Check case where browser is not at 100% zoom and so, double reply is returned
 */
@Test(groups = { "ut" })
public void testScrollPositionWithZoomFactor() {
    when(driver.executeScript(anyString())).thenReturn(Arrays.asList(120.5, 80.67));
    Point point = ((CustomEventFiringWebDriver) eventDriver).getScrollPosition();
    // check we get the window dimension
    Assert.assertEquals(point.x, 120);
    Assert.assertEquals(point.y, 80);
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Point(org.openqa.selenium.Point) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 65 with CustomEventFiringWebDriver

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

the class TestCustomEventFiringWebDriver method testContentDimensionNonWebTest.

/**
 * For non web test, dimension is returned from driver call, not javascript
 */
@Test(groups = { "ut" })
public void testContentDimensionNonWebTest() {
    eventDriver = spy(new CustomEventFiringWebDriver(driver, null, null, false, DriverMode.LOCAL, null, null).register(new DriverExceptionListener()));
    when(driver.executeScript(anyString())).thenReturn(Arrays.asList(120L, 80L));
    Dimension dim = ((CustomEventFiringWebDriver) eventDriver).getContentDimension();
    // check we get the window dimension
    Assert.assertEquals(dim.height, 100);
    Assert.assertEquals(dim.width, 100);
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) DriverExceptionListener(com.seleniumtests.driver.DriverExceptionListener) Dimension(org.openqa.selenium.Dimension) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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