Search in sources :

Example 16 with WebElementWrapper

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);
}
Also used : WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) MyPage(org.definitylabs.flue2ent.data.MyPage) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 17 with WebElementWrapper

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);
        }
    };
}
Also used : WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) Before(org.junit.Before)

Example 18 with WebElementWrapper

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);
}
Also used : By(org.openqa.selenium.By) FindElementBy(org.definitylabs.flue2ent.element.FindElementBy) List(java.util.List) WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) Test(org.junit.Test)

Example 19 with WebElementWrapper

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);
}
Also used : Point(org.openqa.selenium.Point) Dimension(org.openqa.selenium.Dimension) WebElement(org.openqa.selenium.WebElement) WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) Test(org.junit.Test)

Example 20 with WebElementWrapper

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);
}
Also used : StaleElementReferenceException(org.openqa.selenium.StaleElementReferenceException) WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) Test(org.junit.Test)

Aggregations

WebElementWrapper (org.definitylabs.flue2ent.element.WebElementWrapper)40 Test (org.junit.Test)35 WebElement (org.openqa.selenium.WebElement)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 FakeTableElement (org.definitylabs.flue2ent.data.FakeTableElement)5 Before (org.junit.Before)5 MyPage (org.definitylabs.flue2ent.data.MyPage)4 FindElementBy (org.definitylabs.flue2ent.element.FindElementBy)4 By (org.openqa.selenium.By)4 SubPage (org.definitylabs.flue2ent.data.SubPage)2 List (java.util.List)1 TableElement (org.definitylabs.flue2ent.element.table.TableElement)1 Dimension (org.openqa.selenium.Dimension)1 Point (org.openqa.selenium.Point)1 StaleElementReferenceException (org.openqa.selenium.StaleElementReferenceException)1 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)1