Search in sources :

Example 1 with SnapshotCheckType

use of com.seleniumtests.driver.screenshots.SnapshotCheckType in project seleniumRobot by bhecquet.

the class TestSnapshotCheckType method testExcludeElementOutsideViewport1.

/**
 * Check element excluded from captured viewport but outside of it is not kept
 * element to exclude 'x' is greater than enclosing element top right position
 */
@Test(groups = { "ut" })
public void testExcludeElementOutsideViewport1() {
    when(elementToExclude1.getRect()).thenReturn(new Rectangle(101, 20, 3, 4));
    when(snapshotTarget.isPageTarget()).thenReturn(false);
    when(snapshotTarget.isElementTarget()).thenReturn(false);
    when(snapshotTarget.isViewportTarget()).thenReturn(true);
    when(snapshotTarget.getSnapshotRectangle()).thenReturn(new Rectangle(0, 0, 100, 100));
    SnapshotCheckType checkType = SnapshotCheckType.FULL.exclude(elementToExclude1);
    checkType.check(snapshotTarget);
    Assert.assertEquals(checkType.getExcludeElementsRect().size(), 0);
}
Also used : Rectangle(org.openqa.selenium.Rectangle) SnapshotCheckType(com.seleniumtests.driver.screenshots.SnapshotCheckType) MockitoTest(com.seleniumtests.MockitoTest) Test(org.testng.annotations.Test)

Example 2 with SnapshotCheckType

use of com.seleniumtests.driver.screenshots.SnapshotCheckType in project seleniumRobot by bhecquet.

the class TestSnapshotCheckType method testExcludeElementInsideViewport.

/**
 * Check element excluded from captured viewport is kept
 */
@Test(groups = { "ut" })
public void testExcludeElementInsideViewport() {
    when(elementToExclude1.getRect()).thenReturn(new Rectangle(1, 2, 3, 4));
    when(snapshotTarget.isPageTarget()).thenReturn(false);
    when(snapshotTarget.isElementTarget()).thenReturn(false);
    when(snapshotTarget.isViewportTarget()).thenReturn(true);
    when(snapshotTarget.getSnapshotRectangle()).thenReturn(new Rectangle(0, 0, 100, 100));
    SnapshotCheckType checkType = SnapshotCheckType.FULL.exclude(elementToExclude1);
    checkType.check(snapshotTarget);
    Assert.assertEquals(checkType.getExcludeElementsRect().size(), 1);
    Assert.assertEquals(checkType.getExcludeElementsRect().get(0), new Rectangle(1, 2, 3, 4));
}
Also used : Rectangle(org.openqa.selenium.Rectangle) SnapshotCheckType(com.seleniumtests.driver.screenshots.SnapshotCheckType) MockitoTest(com.seleniumtests.MockitoTest) Test(org.testng.annotations.Test)

Example 3 with SnapshotCheckType

use of com.seleniumtests.driver.screenshots.SnapshotCheckType in project seleniumRobot by bhecquet.

the class TestSnapshotCheckType method testExcludeElementOutsideElement2.

/**
 * Check element excluded from captured element but outside of it is not kept
 * element to exclude 'x' is lower than enclosing element left position
 */
@Test(groups = { "ut" })
public void testExcludeElementOutsideElement2() {
    when(elementToExclude1.getRect()).thenReturn(new Rectangle(0, 0, 3, 4));
    when(snapshotTarget.getElement()).thenReturn(element);
    when(snapshotTarget.isPageTarget()).thenReturn(false);
    when(snapshotTarget.isElementTarget()).thenReturn(true);
    when(snapshotTarget.getSnapshotRectangle()).thenReturn(new Rectangle(1, 0, 100, 100));
    SnapshotCheckType checkType = SnapshotCheckType.FULL.exclude(elementToExclude1);
    checkType.check(snapshotTarget);
    Assert.assertEquals(checkType.getExcludeElementsRect().size(), 0);
}
Also used : Rectangle(org.openqa.selenium.Rectangle) SnapshotCheckType(com.seleniumtests.driver.screenshots.SnapshotCheckType) MockitoTest(com.seleniumtests.MockitoTest) Test(org.testng.annotations.Test)

Example 4 with SnapshotCheckType

use of com.seleniumtests.driver.screenshots.SnapshotCheckType in project seleniumRobot by bhecquet.

the class TestSnapshotCheckType method testExcludeElementOutsideElement5.

/**
 * Check element excluded from captured element but outside of it is not kept
 * element to exclude is wider than enclosing element
 */
@Test(groups = { "ut" })
public void testExcludeElementOutsideElement5() {
    when(elementToExclude1.getRect()).thenReturn(new Rectangle(0, 0, 101, 4));
    when(snapshotTarget.getElement()).thenReturn(element);
    when(snapshotTarget.isPageTarget()).thenReturn(false);
    when(snapshotTarget.isElementTarget()).thenReturn(true);
    when(snapshotTarget.getSnapshotRectangle()).thenReturn(new Rectangle(0, 0, 100, 100));
    SnapshotCheckType checkType = SnapshotCheckType.FULL.exclude(elementToExclude1);
    checkType.check(snapshotTarget);
    Assert.assertEquals(checkType.getExcludeElementsRect().size(), 0);
}
Also used : Rectangle(org.openqa.selenium.Rectangle) SnapshotCheckType(com.seleniumtests.driver.screenshots.SnapshotCheckType) MockitoTest(com.seleniumtests.MockitoTest) Test(org.testng.annotations.Test)

Example 5 with SnapshotCheckType

use of com.seleniumtests.driver.screenshots.SnapshotCheckType in project seleniumRobot by bhecquet.

the class TestSnapshotCheckType method testExcludeElementOutsideElement6.

/**
 * Check element excluded from captured element but outside of it is not kept
 * element to exclude is higher than enclosing element
 */
@Test(groups = { "ut" })
public void testExcludeElementOutsideElement6() {
    when(elementToExclude1.getRect()).thenReturn(new Rectangle(0, 0, 3, 101));
    when(snapshotTarget.getElement()).thenReturn(element);
    when(snapshotTarget.isPageTarget()).thenReturn(false);
    when(snapshotTarget.isElementTarget()).thenReturn(true);
    when(snapshotTarget.getSnapshotRectangle()).thenReturn(new Rectangle(0, 0, 100, 100));
    SnapshotCheckType checkType = SnapshotCheckType.FULL.exclude(elementToExclude1);
    checkType.check(snapshotTarget);
    Assert.assertEquals(checkType.getExcludeElementsRect().size(), 0);
}
Also used : Rectangle(org.openqa.selenium.Rectangle) SnapshotCheckType(com.seleniumtests.driver.screenshots.SnapshotCheckType) MockitoTest(com.seleniumtests.MockitoTest) Test(org.testng.annotations.Test)

Aggregations

SnapshotCheckType (com.seleniumtests.driver.screenshots.SnapshotCheckType)19 MockitoTest (com.seleniumtests.MockitoTest)18 Rectangle (org.openqa.selenium.Rectangle)18 Test (org.testng.annotations.Test)18 WebDriverException (org.openqa.selenium.WebDriverException)1 BeforeMethod (org.testng.annotations.BeforeMethod)1