use of org.definitylabs.flue2ent.element.WebElementWrapper in project flue2ent by DefinityLabs.
the class WebsiteTest method element_returnsFunction.
@Test
public void element_returnsFunction() {
By byTable = By.tagName("table");
WebElementWrapper mockedElement = mock(WebElementWrapper.class);
Website website = mock(Website.class);
when(website.findElement(byTable)).thenReturn(mockedElement);
Function<Website, WebElementWrapper> element = Website.element(byTable);
WebElementWrapper response = element.apply(website);
verify(website).findElement(byTable);
assertThat(response).isSameAs(mockedElement);
}
use of org.definitylabs.flue2ent.element.WebElementWrapper in project flue2ent by DefinityLabs.
the class WebsiteTest method findElements_callsDriverFindElements.
@Test
public void findElements_callsDriverFindElements() {
By bySelect = By.tagName("select");
WebElement mockedSelectOne = mock(WebElement.class);
WebElement mockedSelectTwo = mock(WebElement.class);
when(driver.findElements(bySelect)).thenReturn(Arrays.asList(mockedSelectOne, mockedSelectTwo));
Website website = Website.with(driver).visit(TEST_WEBSITE_URL);
List<WebElementWrapper> selects = website.findElements(bySelect);
verify(driver).findElements(bySelect);
assertThat(selects).hasSize(2);
assertThat(selects.get(0).webElement()).isSameAs(mockedSelectOne);
assertThat(selects.get(1).webElement()).isSameAs(mockedSelectTwo);
}
use of org.definitylabs.flue2ent.element.WebElementWrapper in project flue2ent by DefinityLabs.
the class WebsiteTest method findElement_callsDriverFindElement.
@Test
public void findElement_callsDriverFindElement() {
By bySelect = By.tagName("select");
WebElement mockedSelect = mock(WebElement.class);
when(driver.findElement(bySelect)).thenReturn(mockedSelect);
Website website = Website.with(driver).visit(TEST_WEBSITE_URL);
WebElementWrapper select = website.findElement(bySelect);
verify(driver).findElement(bySelect);
assertThat(select.webElement()).isSameAs(mockedSelect);
}
use of org.definitylabs.flue2ent.element.WebElementWrapper in project flue2ent by DefinityLabs.
the class WebsiteTest method at_setsDriverAndResponseParameter.
@Test
public void at_setsDriverAndResponseParameter() {
WebElementWrapper webElementWrapper = mock(WebElementWrapper.class);
PageObject<WebElementWrapper> webContentDsl = mock(PageObject.class);
when(webContentDsl.getResponse()).thenReturn(webElementWrapper);
Website website = Website.with(driver).visit(TEST_WEBSITE_URL);
WebElementWrapper at = website.at(webContentDsl);
verify(webContentDsl).setWebsite(website);
assertThat(at).isSameAs(webElementWrapper);
}
use of org.definitylabs.flue2ent.element.WebElementWrapper in project flue2ent by DefinityLabs.
the class ListItemElementTest method text_callsWebElementText.
@Test
public void text_callsWebElementText() {
AbstractListElement<? extends ListItemElement> listElement = mock(AbstractListElement.class);
WebElement webElement = mock(WebElement.class);
String elementText = "element text";
when(webElement.getText()).thenReturn(elementText);
ListItemElement listItemElement = new ListItemElement(listElement, new WebElementWrapper(webElement));
String text = listItemElement.text();
assertThat(text).isEqualTo(elementText);
}
Aggregations