use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestHtmlElement method testFindNthSubElement.
/**
* Check we get the Nth sub-element of our root element "el"
*/
@Test(groups = { "ut" })
public void testFindNthSubElement() throws Exception {
HtmlElement subEl = el.findElement(By.name("subEl"), 1);
Assert.assertEquals(subEl.getElement().toString(), "subElement2");
finalCheck(true);
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestHtmlElement method testIsElementPresentNotFoundWithFrame.
/**
* Check that element is not found if frame is not found
* @throws Exception
*/
@Test(groups = { "ut" })
public void testIsElementPresentNotFoundWithFrame() throws Exception {
HtmlElement present = new HtmlElement("element", By.id("present"), frame);
when(driver.findElement(By.id("present"))).thenReturn(el);
when(driver.findElement(By.id("frame"))).thenThrow(NoSuchElementException.class);
when(driver.findElements(By.id("frame"))).thenReturn(new ArrayList<>());
LocalDateTime start = LocalDateTime.now();
boolean exceptionRaised = false;
try {
present.waitForPresent(1);
} catch (TimeoutException e) {
exceptionRaised = true;
}
verify(driver.switchTo(), never()).frame(any(WebElement.class));
Assert.assertTrue(exceptionRaised);
Assert.assertTrue(LocalDateTime.now().minus(900, ChronoUnit.MILLIS).isAfter(start));
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestPageObject2 method testCaptureElementSnapshotWithCheckAndDelay.
@Test(groups = { "ut" })
public void testCaptureElementSnapshotWithCheckAndDelay() throws IOException {
SeleniumTestsContextManager.getThreadContext().setSnapshotScrollDelay(100);
page.setScreenshotUtil(screenshotUtil);
page.captureElementSnapshot("img", new HtmlElement("", By.id("el")), SnapshotCheckType.TRUE);
// check scroll delay is applied
verify(screenshotUtil).capture(any(SnapshotTarget.class), eq(ScreenShot.class), eq(100));
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestPageObject2 method testCaptureElementSnapshotWithoutCheckAndDelay.
/**
* scrollDelay s set, but snapshot is not performed for control
* @throws IOException
*/
@Test(groups = { "ut" })
public void testCaptureElementSnapshotWithoutCheckAndDelay() throws IOException {
SeleniumTestsContextManager.getThreadContext().setSnapshotScrollDelay(100);
page.setScreenshotUtil(screenshotUtil);
page.captureElementSnapshot("img", new HtmlElement("", By.id("el")), SnapshotCheckType.FALSE);
// check scroll delay is 0 by default
verify(screenshotUtil).capture(any(SnapshotTarget.class), eq(ScreenShot.class), eq(0));
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestPageObject2 method testCaptureElementSnapshotWithCheckNoName.
/**
* Capture element snapshot and sends it to selenium server. No name is provided
* ScenarioException should be raised
*
* @throws IOException
*/
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testCaptureElementSnapshotWithCheckNoName() throws IOException {
page.setScreenshotUtil(screenshotUtil);
page.captureElementSnapshot("", new HtmlElement("", By.id("el")), SnapshotCheckType.TRUE);
}
Aggregations