use of com.seleniumtests.driver.screenshots.SnapshotCheckType in project seleniumRobot by bhecquet.
the class TestSnapshotCheckType method testExcludeElementOutsideViewport4.
/**
* Check element excluded from captured viewport but outside of it is not kept
* element to exclude 'y' is higher than enclosing top position
*/
@Test(groups = { "ut" })
public void testExcludeElementOutsideViewport4() {
when(elementToExclude1.getRect()).thenReturn(new Rectangle(0, 101, 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);
}
use of com.seleniumtests.driver.screenshots.SnapshotCheckType in project seleniumRobot by bhecquet.
the class TestSnapshotCheckType method testExcludeElementFromPageWithError.
/**
* Error getting element to exclude, it's not kept but we continue
*/
@Test(groups = { "ut" })
public void testExcludeElementFromPageWithError() {
when(elementToExclude1.getRect()).thenThrow(new WebDriverException("error"));
when(snapshotTarget.isPageTarget()).thenReturn(true);
SnapshotCheckType checkType = SnapshotCheckType.FULL.exclude(elementToExclude1);
checkType.check(snapshotTarget);
Assert.assertEquals(checkType.getExcludeElementsRect().size(), 0);
}
use of com.seleniumtests.driver.screenshots.SnapshotCheckType in project seleniumRobot by bhecquet.
the class TestSnapshotCheckType method testExcludeElementOutsideElement3.
/**
* Check element excluded from captured element but outside of it is not kept
* element to exclude 'y' is lower than enclosing top position
*/
@Test(groups = { "ut" })
public void testExcludeElementOutsideElement3() {
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(0, 1, 100, 100));
SnapshotCheckType checkType = SnapshotCheckType.FULL.exclude(elementToExclude1);
checkType.check(snapshotTarget);
Assert.assertEquals(checkType.getExcludeElementsRect().size(), 0);
}
use of com.seleniumtests.driver.screenshots.SnapshotCheckType in project seleniumRobot by bhecquet.
the class TestSnapshotCheckType method testExcludeElementsFromPage.
@Test(groups = { "ut" })
public void testExcludeElementsFromPage() {
when(elementToExclude1.getRect()).thenReturn(new Rectangle(1, 2, 3, 4));
when(elementToExclude2.getRect()).thenReturn(new Rectangle(5, 6, 7, 8));
when(snapshotTarget.isPageTarget()).thenReturn(true);
SnapshotCheckType checkType = SnapshotCheckType.FULL.exclude(Arrays.asList(elementToExclude1, elementToExclude2));
checkType.check(snapshotTarget);
Assert.assertEquals(checkType.getExcludeElementsRect().size(), 2);
Assert.assertEquals(checkType.getExcludeElementsRect().get(0), new Rectangle(1, 2, 3, 4));
Assert.assertEquals(checkType.getExcludeElementsRect().get(1), new Rectangle(5, 6, 7, 8));
}
Aggregations