use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class ServiceWorkerIT method offlineTsView_navigateToOtherTsView_navigationSuccessful.
@Test
public void offlineTsView_navigateToOtherTsView_navigationSuccessful() throws IOException {
getDriver().get(getRootURL() + "/about");
waitForDevServer();
waitForServiceWorkerReady();
MatcherAssert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/about"));
// Set offline network conditions in ChromeDriver
setConnectionType(NetworkConnection.ConnectionType.AIRPLANE_MODE);
try {
$("main-view").first().$("a").id("menu-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());
MatcherAssert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/another"));
TestBenchElement anotherView = $("another-view").first();
Assert.assertTrue(anotherView.$("*").id("another-content").isDisplayed());
} finally {
// Reset network conditions back
setConnectionType(NetworkConnection.ConnectionType.ALL);
}
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class NavigateBetweenViewsIT method openFlowView_isConnectedOnAttach.
@Test
public void openFlowView_isConnectedOnAttach() {
getDriver().get(getRootURL() + "/hello");
waitForDevServer();
Assert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/hello"));
assertIsConnected();
// Navigate away and back
$(NativeButtonElement.class).id(NAVIGATE_ABOUT).click();
waitUntil(input -> $("about-view").first().$("a").id("navigate-hello").isDisplayed());
TestBenchElement aboutView = $("about-view").first();
aboutView.$("*").id("navigate-hello").click();
assertIsConnected();
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class ParentThemeIT method componentThemeIsApplied_childThemeTextColorIsApplied.
@Test
public void componentThemeIsApplied_childThemeTextColorIsApplied() {
open();
TestBenchElement myField = $(TestBenchElement.class).id(MY_POLYMER_ID);
TestBenchElement input = myField.$("vaadin-input-container").attribute("part", "input-field").first();
Assert.assertEquals("Polymer text field should have red background", "rgba(255, 0, 0, 1)", input.getCssValue("background-color"));
Assert.assertEquals("Text field should have color as green", "rgba(0, 128, 0, 1)", input.getCssValue("color"));
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class FrontendLiveReloadIT method liveReloadOnTouchedFrontendFile.
@Test
public void liveReloadOnTouchedFrontendFile() {
open();
// when: the frontend code is updated
WebElement codeField = findElement(By.id(FrontendLiveReloadView.FRONTEND_CODE_TEXT));
String oldCode = getValue(codeField);
String newCode = oldCode.replace("Custom component contents", "Updated component contents");
codeField.clear();
codeField.sendKeys(newCode);
waitForElementPresent(By.id(FrontendLiveReloadView.FRONTEND_CODE_UPDATE_BUTTON));
WebElement liveReloadTrigger = findElement(By.id(FrontendLiveReloadView.FRONTEND_CODE_UPDATE_BUTTON));
liveReloadTrigger.click();
// when: the page has reloaded
waitForLiveReload();
// then: the frontend changes are visible in the DOM
TestBenchElement customComponent = $("*").id(FrontendLiveReloadView.CUSTOM_COMPONENT);
TestBenchElement embeddedDiv = customComponent.$("*").id("custom-div");
Assert.assertEquals("Updated component contents", embeddedDiv.getText());
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class ApplicationThemeComponentIT method componentThemeIsApplied.
@Test
public void componentThemeIsApplied() {
open();
final TestBenchElement themedComponent = $("themed-component").first();
final TestBenchElement embeddedComponent = themedComponent.$(DivElement.class).id(EMBEDDED_ID);
TestBenchElement myField = embeddedComponent.$(TestBenchElement.class).id(MY_COMPONENT_ID);
TestBenchElement input = myField.$("vaadin-input-container").attribute("part", "input-field").first();
Assert.assertEquals("Polymer text field should have red background", "rgba(255, 0, 0, 1)", input.getCssValue("background-color"));
}
Aggregations