Search in sources :

Example 96 with TestBenchElement

use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.

the class NavigateBetweenViewsIT method openFlowView_navigateToTsView_navigationSuccessful.

@Test
public void openFlowView_navigateToTsView_navigationSuccessful() {
    getDriver().get(getRootURL() + "/hello");
    waitForDevServer();
    Assert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/hello"));
    $(NativeButtonElement.class).id(NAVIGATE_ABOUT).click();
    // Wait for component inside shadowroot as there is no vaadin
    // to wait for as with server-side
    waitUntil(input -> $("about-view").first().$("a").id("navigate-hello").isDisplayed());
    Assert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/about"));
    TestBenchElement aboutView = $("about-view").first();
    Assert.assertTrue(aboutView.$("*").id("navigate-hello").isDisplayed());
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 97 with TestBenchElement

use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.

the class ServiceWorkerIT method offlineDeepPath_reload_viewReloaded_baseUrlRewritten.

@Test
public void offlineDeepPath_reload_viewReloaded_baseUrlRewritten() throws IOException {
    getDriver().get(getRootURL() + "/");
    waitForDevServer();
    waitForServiceWorkerReady();
    // Set offline network conditions in ChromeDriver
    setConnectionType(NetworkConnection.ConnectionType.AIRPLANE_MODE);
    try {
        $("main-view").first().$("a").id("menu-deep-another").click();
        // Wait for component inside shadow root as there is no vaadin
        // to wait for as with server-side
        waitUntil(input -> $("another-view").first().$("div").id("another-content").isDisplayed());
        // Reload the page in offline mode
        executeScript("window.location.reload();");
        waitUntil(webDriver -> ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete"));
        MatcherAssert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/another"));
        TestBenchElement anotherView = $("another-view").first();
        Assert.assertTrue(anotherView.$("*").id("another-content").isDisplayed());
        // Verify <base href> by navigating with a relative link
        $("main-view").first().$("a").id("menu-about").click();
        MatcherAssert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/about"));
        Assert.assertNotNull("Should have <about-view> in DOM", findElement(By.tagName("about-view")));
    } finally {
        // Reset network conditions back
        setConnectionType(NetworkConnection.ConnectionType.ALL);
    }
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeDeviceTest(com.vaadin.flow.testutil.ChromeDeviceTest)

Example 98 with TestBenchElement

use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.

the class UpgradeElementIT method twoWayDatabindingForUpgradedElement.

@Test
public void twoWayDatabindingForUpgradedElement() {
    open();
    findElement(By.id("upgrade")).click();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    WebElement input = template.$(TestBenchElement.class).id("input");
    new Actions(getDriver()).click(input).sendKeys("foo").sendKeys(Keys.ENTER).build().perform();
    WebElement result = findElement(By.id("text-update"));
    Assert.assertEquals("foo", result.getText());
}
Also used : Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 99 with TestBenchElement

use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.

the class ListBindingIT method listDataBinding.

@Test
public void listDataBinding() {
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    checkInitialState(template);
    checkModelItemWorks(template);
    // Before running those methods list is set to ["1", "2", "3"]
    // see (ListBindingView.INITIAL_STATE)
    assertMethodWorksCorrectly("addElement", template, "1", "2", "3", "4");
    assertMethodWorksCorrectly("addElementByIndex", template, "4", "1", "2", "3");
    assertMethodWorksCorrectly("addNumerousElements", template, "1", "2", "3", "4", "5");
    assertMethodWorksCorrectly("addNumerousElementsByIndex", template, "4", "5", "1", "2", "3");
    assertMethodWorksCorrectly("clearList", template);
    assertMethodWorksCorrectly("removeSecondElementByIndex", template, "1", "3");
    assertMethodWorksCorrectly("removeFirstElementWithIterator", template, "2", "3");
    assertMethodWorksCorrectly("swapFirstAndSecond", template, "2", "1", "3");
    assertMethodWorksCorrectly("sortDescending", template, "3", "2", "1");
    assertMethodWorksCorrectly("setInitialStateToEachMessage", template, ListBindingView.INITIAL_STATE, ListBindingView.INITIAL_STATE, ListBindingView.INITIAL_STATE);
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 100 with TestBenchElement

use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.

the class OneWayPolymerBindingIT method initialModelValueIsPresentAndModelUpdatesNormally.

// Numerous tests are carried out in the single test case, because it's
// expensive to launch numerous Chrome instances
@Test
public void initialModelValueIsPresentAndModelUpdatesNormally() {
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    checkInitialState(template);
    checkTemplateModel(template);
    template.$(TestBenchElement.class).id("changeModelValue").click();
    checkStateAfterClick(template);
    checkTemplateModel(template);
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Aggregations

TestBenchElement (com.vaadin.testbench.TestBenchElement)154 Test (org.junit.Test)120 ChromeBrowserTest (com.vaadin.flow.testutil.ChromeBrowserTest)98 WebElement (org.openqa.selenium.WebElement)46 By (org.openqa.selenium.By)6 DivElement (com.vaadin.flow.component.html.testbench.DivElement)5 List (java.util.List)5 Assert (org.junit.Assert)5 SpanElement (com.vaadin.flow.component.html.testbench.SpanElement)4 ChromeDeviceTest (com.vaadin.flow.testutil.ChromeDeviceTest)4 NativeButtonElement (com.vaadin.flow.component.html.testbench.NativeButtonElement)3 File (java.io.File)3 Ignore (org.junit.Ignore)3 ButtonElement (com.vaadin.flow.component.button.testbench.ButtonElement)2 DevModeGizmoElement (com.vaadin.flow.testutil.DevModeGizmoElement)2 Optional (java.util.Optional)2 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)2 WebDriver (org.openqa.selenium.WebDriver)2 ParagraphElement (com.vaadin.flow.component.html.testbench.ParagraphElement)1 TextFieldElement (com.vaadin.flow.component.textfield.testbench.TextFieldElement)1