use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestFrameElement method testUseElementInsideFrameWithIndex.
/**
* issue #276: Check that we can switch to a frame by index
* @throws Exception
*/
@Test(groups = { "ut" })
public void testUseElementInsideFrameWithIndex() throws Exception {
ArgumentCaptor<WebElement> frameArgument = ArgumentCaptor.forClass(WebElement.class);
FrameElement frame = new FrameElement("", By.tagName("iframe"), 1);
HtmlElement el = new HtmlElement("", By.id("el"), frame);
el.click();
verify(locator).frame(frameArgument.capture());
Assert.assertEquals(frameArgument.getValue().getText(), "222");
verify(locator).defaultContent();
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestFrameElement method testUseElementInsideFrame.
@Test(groups = { "ut" })
public void testUseElementInsideFrame() throws Exception {
ArgumentCaptor<WebElement> frameArgument = ArgumentCaptor.forClass(WebElement.class);
FrameElement frame = new FrameElement("", By.id("frameId"));
HtmlElement el = new HtmlElement("", By.id("el"), frame);
el.click();
verify(locator).frame(frameArgument.capture());
Assert.assertEquals(frameArgument.getValue().getText(), "111");
verify(locator).defaultContent();
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestFrameElement method testUseElementInsideFrameWithWrongIndex.
/**
* issue #276: Check a clear error is raised when an invalid index is given for finding a frame
* @throws Exception
*/
@Test(groups = { "ut" }, expectedExceptions = NoSuchFrameException.class)
public void testUseElementInsideFrameWithWrongIndex() throws Exception {
FrameElement frame = new FrameElement("", By.tagName("iframe"), 2);
HtmlElement el = new HtmlElement("", By.id("el"), frame);
el.click();
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestHtmlElement method testFindSubElement.
/**
* Check we get the first sub-element of our root element "el"
*/
@Test(groups = { "ut" })
public void testFindSubElement() throws Exception {
HtmlElement subEl = el.findElement(By.name("subEl"));
Assert.assertEquals(subEl.getElement().toString(), "subElement1");
finalCheck(true);
}
use of com.seleniumtests.uipage.htmlelements.HtmlElement in project seleniumRobot by bhecquet.
the class TestHtmlElement method testIsElementPresentFoundWithFrame.
/**
* Check that element is found with frame
* @throws Exception
*/
@Test(groups = { "ut" })
public void testIsElementPresentFoundWithFrame() throws Exception {
HtmlElement present = new HtmlElement("element", By.id("present"), frame);
when(driver.findElement(By.id("present"))).thenReturn(el);
LocalDateTime start = LocalDateTime.now();
boolean exceptionRaised = false;
try {
present.waitForPresent(5);
} catch (TimeoutException e) {
exceptionRaised = true;
}
verify(driver.switchTo()).frame(any(WebElement.class));
Assert.assertFalse(exceptionRaised);
Assert.assertTrue(LocalDateTime.now().minusSeconds(5).isBefore(start));
}
Aggregations