Search in sources :

Example 21 with MyPage

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

the class AbstractWebElementProxyTest method findByLabel_login_returnsWebElement.

@Test
public void findByLabel_login_returnsWebElement() {
    when(website.findElement(ExtendedBy.byLabel("Login"))).thenReturn(new WebElementWrapper(webElement));
    MyPage myPage = newInstance(MyPage.class, website);
    WebElementWrapper login = myPage.login();
    assertThat(login.webElement()).isSameAs(webElement);
}
Also used : MyPage(org.definitylabs.flue2ent.data.MyPage) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 22 with MyPage

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

the class AbstractWebElementProxyTest method findByTagName_results_returnsTableElement.

@Test
public void findByTagName_results_returnsTableElement() {
    when(website.findElement(By.tagName("table"))).thenReturn(new WebElementWrapper(webElement));
    MyPage myPage = newInstance(MyPage.class, website);
    TableElement results = myPage.results();
    assertThat(results.webElement().webElement()).isSameAs(webElement);
}
Also used : TableElement(org.definitylabs.flue2ent.element.table.TableElement) MyPage(org.definitylabs.flue2ent.data.MyPage) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 23 with MyPage

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

the class PageObjectProxyTest method webProxy_subPage_returnsWebElement.

@Test
public void webProxy_subPage_returnsWebElement() {
    WebElement h1Element = mock(WebElement.class);
    when(website.findElement(By.cssSelector(".subPage"))).thenReturn(new WebElementWrapper(webElement));
    when(website.findElement(By.tagName("h1"))).thenReturn(new WebElementWrapper(h1Element));
    MyPage myPage = PageObjectProxy.newInstance(MyPage.class, website);
    SubPage subPage = myPage.subPage();
    assertThat(subPage.title().webElement()).isSameAs(h1Element);
}
Also used : SubPage(org.definitylabs.flue2ent.data.SubPage) WebElement(org.openqa.selenium.WebElement) WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) MyPage(org.definitylabs.flue2ent.data.MyPage) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 24 with MyPage

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

the class PageObjectProxyTest method findByCssUsingProxy_nothing_returnsWebElement.

@Test
public void findByCssUsingProxy_nothing_returnsWebElement() {
    WebElement h1Element = mock(WebElement.class);
    when(website.findElement(By.cssSelector(".subPage"))).thenReturn(new WebElementWrapper(webElement));
    when(website.findElement(By.tagName("h1"))).thenReturn(new WebElementWrapper(h1Element));
    MyPage myPage = PageObjectProxy.newInstance(MyPage.class, website);
    SubPage subPage = myPage.subPage();
    assertThat(subPage.title().webElement()).isSameAs(h1Element);
}
Also used : SubPage(org.definitylabs.flue2ent.data.SubPage) WebElement(org.openqa.selenium.WebElement) WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) MyPage(org.definitylabs.flue2ent.data.MyPage) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 25 with MyPage

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

the class PageObjectProxyTest method findByElements_links_returnsWebElementList.

@Test
public void findByElements_links_returnsWebElementList() {
    WebElement linkOne = mock(WebElement.class);
    when(linkOne.getText()).thenReturn("Link One");
    WebElement linkTwo = mock(WebElement.class);
    when(linkTwo.getText()).thenReturn("Link Two");
    when(website.findElements(By.tagName("a"))).thenReturn(Arrays.asList(new WebElementWrapper(linkOne), new WebElementWrapper(linkTwo)));
    MyPage myPage = PageObjectProxy.newInstance(MyPage.class, website);
    List<String> links = myPage.links();
    assertThat(links).hasSize(2);
    assertThat(links.get(0)).isEqualTo("Link One");
    assertThat(links.get(1)).isEqualTo("Link Two");
}
Also used : WebElement(org.openqa.selenium.WebElement) WebElementWrapper(org.definitylabs.flue2ent.element.WebElementWrapper) MyPage(org.definitylabs.flue2ent.data.MyPage) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

MyPage (org.definitylabs.flue2ent.data.MyPage)25 Test (org.junit.Test)25 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 WebElement (org.openqa.selenium.WebElement)6 WebElementWrapper (org.definitylabs.flue2ent.element.WebElementWrapper)4 SubPage (org.definitylabs.flue2ent.data.SubPage)2 Method (java.lang.reflect.Method)1 SelectElement (org.definitylabs.flue2ent.element.list.SelectElement)1 TableElement (org.definitylabs.flue2ent.element.table.TableElement)1