Search in sources :

Example 1 with Website

use of org.definitylabs.flue2ent.Website in project flue2ent by DefinityLabs.

the class WaiterPluginTest method expectedCondition_until_callsWaitUntil.

@Test
public void expectedCondition_until_callsWaitUntil() {
    WaiterPlugin waiter = new WaiterPlugin(website);
    WebElement mockedElement = mock(WebElement.class);
    when(wait.until(any())).thenReturn(mockedElement);
    ExpectedCondition<WebElement> expectedCondition = driver -> mockedElement;
    WebElement element = waiter.until(expectedCondition);
    verify(wait).until(same(expectedCondition));
    assertThat(element).isSameAs(mockedElement);
}
Also used : Arrays(java.util.Arrays) Matchers.same(org.mockito.Matchers.same) Mock(org.mockito.Mock) WebDriver(org.openqa.selenium.WebDriver) RunWith(org.junit.runner.RunWith) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Function(java.util.function.Function) Supplier(java.util.function.Supplier) TimeUnit(java.util.concurrent.TimeUnit) Matchers.any(org.mockito.Matchers.any) FluentWait(org.openqa.selenium.support.ui.FluentWait) Mockito(org.mockito.Mockito) SeleniumElementCreator(org.definitylabs.flue2ent.element.SeleniumElementCreator) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Website(org.definitylabs.flue2ent.Website) PowerMockRunner(org.powermock.modules.junit4.PowerMockRunner) PowerMockito(org.powermock.api.mockito.PowerMockito) AssertionsForClassTypes.assertThat(org.assertj.core.api.AssertionsForClassTypes.assertThat) Before(org.junit.Before) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with Website

use of org.definitylabs.flue2ent.Website in project flue2ent by DefinityLabs.

the class PageObjectTest method init_isCalledAfterSetWebsite.

@Test
public void init_isCalledAfterSetWebsite() {
    Website mockedWebsite = mock(Website.class);
    doAnswer(invocationOnMock -> invocationOnMock.callRealMethod()).when(webContentDsl).init();
    webContentDsl.setWebsite(mockedWebsite);
    verify(webContentDsl).init();
}
Also used : Website(org.definitylabs.flue2ent.Website) Test(org.junit.Test)

Example 3 with Website

use of org.definitylabs.flue2ent.Website in project flue2ent by DefinityLabs.

the class PageObjectTest method driver_returnsDriver.

@Test
public void driver_returnsDriver() {
    Website mockedWebsite = mock(Website.class);
    WebDriver mockedDriver = mock(WebDriver.class);
    when(mockedWebsite.getDriver()).thenReturn(mockedDriver);
    webContentDsl.setWebsite(mockedWebsite);
    WebDriver driver = webContentDsl.driver();
    assertThat(driver).isSameAs(mockedDriver);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Website(org.definitylabs.flue2ent.Website) Test(org.junit.Test)

Example 4 with Website

use of org.definitylabs.flue2ent.Website in project flue2ent by DefinityLabs.

the class PageObjectTest method website_returnsWebsite.

@Test
public void website_returnsWebsite() {
    Website mockedWebsite = mock(Website.class);
    webContentDsl.setWebsite(mockedWebsite);
    Website website = webContentDsl.website();
    assertThat(website).isSameAs(mockedWebsite);
}
Also used : Website(org.definitylabs.flue2ent.Website) Test(org.junit.Test)

Example 5 with Website

use of org.definitylabs.flue2ent.Website in project flue2ent by DefinityLabs.

the class WaiterPluginTest method driver_until_callsWaitUntil.

@Test
public void driver_until_callsWaitUntil() {
    WaiterPlugin waiter = new WaiterPlugin(website);
    WebElement mockedElement = mock(WebElement.class);
    when(wait.until(any())).thenReturn(mockedElement);
    Function<WebDriver, WebElement> function = driver -> mockedElement;
    WebElement element = waiter.driver().until(function);
    verify(wait).until(same(function));
    assertThat(element).isSameAs(mockedElement);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Arrays(java.util.Arrays) Matchers.same(org.mockito.Matchers.same) Mock(org.mockito.Mock) WebDriver(org.openqa.selenium.WebDriver) RunWith(org.junit.runner.RunWith) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Function(java.util.function.Function) Supplier(java.util.function.Supplier) TimeUnit(java.util.concurrent.TimeUnit) Matchers.any(org.mockito.Matchers.any) FluentWait(org.openqa.selenium.support.ui.FluentWait) Mockito(org.mockito.Mockito) SeleniumElementCreator(org.definitylabs.flue2ent.element.SeleniumElementCreator) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Website(org.definitylabs.flue2ent.Website) PowerMockRunner(org.powermock.modules.junit4.PowerMockRunner) PowerMockito(org.powermock.api.mockito.PowerMockito) AssertionsForClassTypes.assertThat(org.assertj.core.api.AssertionsForClassTypes.assertThat) Before(org.junit.Before) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Website (org.definitylabs.flue2ent.Website)6 Test (org.junit.Test)6 WebDriver (org.openqa.selenium.WebDriver)4 WebElement (org.openqa.selenium.WebElement)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Arrays (java.util.Arrays)2 TimeUnit (java.util.concurrent.TimeUnit)2 Function (java.util.function.Function)2 Supplier (java.util.function.Supplier)2 AssertionsForClassTypes.assertThat (org.assertj.core.api.AssertionsForClassTypes.assertThat)2 SeleniumElementCreator (org.definitylabs.flue2ent.element.SeleniumElementCreator)2 Before (org.junit.Before)2 RunWith (org.junit.runner.RunWith)2 Matchers.any (org.mockito.Matchers.any)2 Matchers.same (org.mockito.Matchers.same)2 Mock (org.mockito.Mock)2 Mockito (org.mockito.Mockito)2 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)2 FluentWait (org.openqa.selenium.support.ui.FluentWait)2 PowerMockito (org.powermock.api.mockito.PowerMockito)2