Search in sources :

Example 11 with SnapshotCheckType

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

the class TestSnapshotCheckType method testExcludeElementOutsideElement4.

/**
 * Check element excluded from captured element but outside of it is not kept
 * element to exclude 'y' is higher than enclosing top position
 */
@Test(groups = { "ut" })
public void testExcludeElementOutsideElement4() {
    when(elementToExclude1.getRect()).thenReturn(new Rectangle(0, 101, 3, 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 12 with SnapshotCheckType

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

the class TestSnapshotCheckType method testExcludeElementInsideElement.

/**
 * Check element excluded from captured element is kept
 */
@Test(groups = { "ut" })
public void testExcludeElementInsideElement() {
    when(elementToExclude1.getRect()).thenReturn(new Rectangle(1, 2, 3, 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(), 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 13 with SnapshotCheckType

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

the class TestSnapshotCheckType method testExcludeElementFromPage.

@Test(groups = { "ut" })
public void testExcludeElementFromPage() {
    when(elementToExclude1.getRect()).thenReturn(new Rectangle(1, 2, 3, 4));
    when(snapshotTarget.isPageTarget()).thenReturn(true);
    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 14 with SnapshotCheckType

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

the class TestSeleniumRobotSnapshotServerConnector method init.

@BeforeMethod(groups = { "ut" })
public void init(final ITestContext testNGCtx) {
    when(element.getRect()).thenReturn(new Rectangle(10, 11, 12, 13));
    SnapshotCheckType snapshotCheckType = SnapshotCheckType.FULL.exclude(element);
    snapshotCheckType.check(SnapshotTarget.PAGE);
    when(snapshot.getScreenshot()).thenReturn(screenshot);
    when(snapshot.getName()).thenReturn("snapshot");
    when(snapshot.getCheckSnapshot()).thenReturn(snapshotCheckType);
    when(screenshot.getImagePath()).thenReturn("img.png");
    when(screenshot.getFullImagePath()).thenReturn("/home/img.png");
}
Also used : Rectangle(org.openqa.selenium.Rectangle) SnapshotCheckType(com.seleniumtests.driver.screenshots.SnapshotCheckType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 15 with SnapshotCheckType

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

the class TestSnapshotCheckType method testExcludeElementFromScreen.

/**
 * When capture is done on screen, no element can be excluded
 */
@Test(groups = { "ut" })
public void testExcludeElementFromScreen() {
    when(elementToExclude1.getRect()).thenReturn(new Rectangle(1, 2, 3, 4));
    when(snapshotTarget.isPageTarget()).thenReturn(false);
    when(snapshotTarget.isElementTarget()).thenReturn(false);
    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