Search in sources :

Example 1 with WebElementWrapper

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

Example 2 with WebElementWrapper

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

Example 3 with WebElementWrapper

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

Example 4 with WebElementWrapper

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

Example 5 with 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);
}
Also used : WebElement(org.openqa.selenium.WebElement) 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