use of org.definitylabs.flue2ent.element.WebElementWrapper in project flue2ent by DefinityLabs.
the class PageObjectProxyTest method findByElement_returnsWebElement.
@Test
public void findByElement_returnsWebElement() {
when(website.findElement(By.name("age"))).thenReturn(new WebElementWrapper(webElement));
MyPage myPage = PageObjectProxy.newInstance(MyPage.class, website);
WebElementWrapper age = myPage.age();
assertThat(age.webElement()).isEqualTo(webElement);
}
use of org.definitylabs.flue2ent.element.WebElementWrapper in project flue2ent by DefinityLabs.
the class AbstractTableElementTest method beforeEach.
@Before
public void beforeEach() {
tableWebElement = new WebElementWrapper(webElement);
this.table = new AbstractTableElement<TableRowElement<TableColumnElement>, TableColumnElement>(tableWebElement) {
@Override
protected TableRowElement<TableColumnElement> createRow(WebElementWrapper webElement) {
return new TableRowElement<>(webElement, this);
}
@Override
protected TableColumnElement createColumn(WebElementWrapper webElement) {
return new TableColumnElement(webElement, this);
}
};
}
use of org.definitylabs.flue2ent.element.WebElementWrapper in project flue2ent by DefinityLabs.
the class WebsiteTest method elements_returnsFunction.
@Test
public void elements_returnsFunction() {
By byTable = By.tagName("table");
WebElementWrapper mockedElement = mock(WebElementWrapper.class);
Website website = mock(Website.class);
when(website.findElements(byTable)).thenReturn(Collections.singletonList(mockedElement));
Function<Website, List<WebElementWrapper>> element = Website.elements(byTable);
List<WebElementWrapper> response = element.apply(website);
verify(website).findElements(byTable);
assertThat(response).hasSize(1);
assertThat(response).contains(mockedElement);
}
use of org.definitylabs.flue2ent.element.WebElementWrapper in project flue2ent by DefinityLabs.
the class ScreenshotRectangleTest method element_whenElementIsWrapper_returnsRectangle.
@Test
public void element_whenElementIsWrapper_returnsRectangle() {
WebElement webElement = mock(WebElement.class);
when(webElement.getLocation()).thenReturn(new Point(5, 10));
when(webElement.getSize()).thenReturn(new Dimension(200, 35));
WebElementWrapper webElementWrapper = new WebElementWrapper(webElement);
ScreenshotRectangle rectangle = ScreenshotRectangle.element(webElementWrapper);
assertThat(rectangle.getX()).isEqualTo(5);
assertThat(rectangle.getY()).isEqualTo(10);
assertThat(rectangle.getWidth()).isEqualTo(200);
assertThat(rectangle.getHeight()).isEqualTo(35);
}
use of org.definitylabs.flue2ent.element.WebElementWrapper in project flue2ent by DefinityLabs.
the class WebsiteTest method get_waitsElementExistAndReturn.
@Test
public void get_waitsElementExistAndReturn() {
WebElementWrapper webElementWrapper = mock(WebElementWrapper.class);
PageObject<WebElementWrapper> webContentDsl = mock(PageObject.class);
when(webContentDsl.getResponse()).thenThrow(new StaleElementReferenceException("element")).thenThrow(new StaleElementReferenceException("element")).thenReturn(webElementWrapper);
Website website = Website.with(driver).visit(TEST_WEBSITE_URL);
WebElementWrapper elementWrapper = website.get(from(webContentDsl));
assertThat(elementWrapper).isSameAs(webElementWrapper);
}
Aggregations