Search in sources :

Example 1 with FakeTableElement

use of org.definitylabs.flue2ent.data.FakeTableElement in project flue2ent by DefinityLabs.

the class WebElementConverterTest method convertTo__returnsSelectElement.

@Test
public void convertTo__returnsSelectElement() throws Exception {
    WebElement rowElementOne = mock(WebElement.class);
    WebElement rowElementTwo = mock(WebElement.class);
    WebElement webElement = mock(WebElement.class);
    WebElementWrapper webElementWrapper = new WebElementWrapper(webElement);
    when(webElement.findElements(By.className("row"))).thenReturn(Arrays.asList(rowElementOne, rowElementTwo));
    FakeTableElement fakeTableElement = (FakeTableElement) WebElementConverter.convertTo(webElementWrapper, "", FakeTableElement.class);
    assertThat(fakeTableElement.rows()).hasSize(2);
    assertThat(fakeTableElement.rows().get(0).webElement()).isEqualTo(rowElementOne);
    assertThat(fakeTableElement.rows().get(1).webElement()).isEqualTo(rowElementTwo);
}
Also used : FakeTableElement(org.definitylabs.flue2ent.data.FakeTableElement) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with FakeTableElement

use of org.definitylabs.flue2ent.data.FakeTableElement in project flue2ent by DefinityLabs.

the class SimpleWebElementDecoratorProxyTest method findElements_rows_returnsWebElementList.

@Test
public void findElements_rows_returnsWebElementList() {
    WebElement rowElementOne = mock(WebElement.class);
    WebElement rowElementTwo = mock(WebElement.class);
    when(webElement.findElements(By.className("row"))).thenReturn(Arrays.asList(rowElementOne, rowElementTwo));
    WebElementWrapper webElementWrapper = new WebElementWrapper(webElement);
    FakeTableElement fakeTableElement = SimpleWebElementDecoratorProxy.newInstance(FakeTableElement.class, webElementWrapper);
    List<WebElementWrapper> rows = fakeTableElement.rows();
    assertThat(rows).hasSize(2);
    assertThat(rows.get(0).webElement()).isSameAs(rowElementOne);
    assertThat(rows.get(1).webElement()).isSameAs(rowElementTwo);
}
Also used : FakeTableElement(org.definitylabs.flue2ent.data.FakeTableElement) WebElement(org.openqa.selenium.WebElement) WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) Test(org.junit.Test)

Example 3 with FakeTableElement

use of org.definitylabs.flue2ent.data.FakeTableElement in project flue2ent by DefinityLabs.

the class SimpleWebElementDecoratorProxyTest method webElement_returnsWebElementWrapperFromDecorator.

@Test
public void webElement_returnsWebElementWrapperFromDecorator() {
    WebElementWrapper webElementWrapper = new WebElementWrapper(webElement);
    FakeTableElement fakeTableElement = SimpleWebElementDecoratorProxy.newInstance(FakeTableElement.class, webElementWrapper);
    WebElementWrapper fakeTableWebElement = fakeTableElement.webElement();
    assertThat(fakeTableWebElement).isSameAs(webElementWrapper);
}
Also used : FakeTableElement(org.definitylabs.flue2ent.data.FakeTableElement) WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) Test(org.junit.Test)

Example 4 with FakeTableElement

use of org.definitylabs.flue2ent.data.FakeTableElement in project flue2ent by DefinityLabs.

the class WebElementWrapperTest method as_whenDecoratorIsSmart_returnsDecorator.

@Test
public void as_whenDecoratorIsSmart_returnsDecorator() {
    WebElementWrapper wrapper = new WebElementWrapper(webElement);
    FakeTableElement fakeTableElement = wrapper.as(FakeTableElement.class);
    assertThat(fakeTableElement).isNotNull();
    Assertions.assertThat(fakeTableElement.webElement()).isSameAs(wrapper);
}
Also used : FakeTableElement(org.definitylabs.flue2ent.data.FakeTableElement) Test(org.junit.Test)

Example 5 with FakeTableElement

use of org.definitylabs.flue2ent.data.FakeTableElement in project flue2ent by DefinityLabs.

the class SimpleWebElementDecoratorProxyTest method findElement_headerRow_returnsNestedElement.

@Test
public void findElement_headerRow_returnsNestedElement() {
    WebElement rowElement = mock(WebElement.class);
    when(webElement.findElement(By.cssSelector(".header .row:nth-child(0)"))).thenReturn(rowElement);
    WebElementWrapper webElementWrapper = new WebElementWrapper(webElement);
    FakeTableElement fakeTableElement = SimpleWebElementDecoratorProxy.newInstance(FakeTableElement.class, webElementWrapper);
    WebElementWrapper rowElementWrapper = fakeTableElement.headerRow(0);
    assertThat(rowElementWrapper.webElement()).isSameAs(rowElement);
}
Also used : FakeTableElement(org.definitylabs.flue2ent.data.FakeTableElement) WebElement(org.openqa.selenium.WebElement) WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) Test(org.junit.Test)

Aggregations

FakeTableElement (org.definitylabs.flue2ent.data.FakeTableElement)7 Test (org.junit.Test)7 WebElementWrapper (org.definitylabs.flue2ent.element.WebElementWrapper)5 WebElement (org.openqa.selenium.WebElement)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1