use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class AfterServerChangesIT method assertAfterServerUpdate.
private void assertAfterServerUpdate(TestBenchElement element, int i) {
WebElement count = element.$(TestBenchElement.class).id("count");
Assert.assertEquals(String.valueOf(i), count.getText());
WebElement delta = element.$(TestBenchElement.class).id("delta");
Assert.assertEquals(Boolean.TRUE.toString(), delta.getText());
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class AfterServerChangesIT method notifyServerUpdateOnTheClientSide.
@Test
public void notifyServerUpdateOnTheClientSide() {
open();
List<TestBenchElement> components = $("after-server-changes").all();
components.forEach(component -> assertAfterServerUpdate(component, 1));
WebElement update = findElement(By.id("update"));
update.click();
components.forEach(component -> assertAfterServerUpdate(component, 2));
findElement(By.id("remove")).click();
update.click();
// The second components is removed
// No exceptions , everything is functional
assertAfterServerUpdate($("after-server-changes").first(), 3);
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class DebugWindowErrorHandlingIT method causeErrors.
private void causeErrors(String nr) {
TestBenchElement input = $("input").id(DebugWindowErrorHandlingView.NUMBER_OF_ERRORS_ID);
// input.setProperty("value", i);
input.clear();
input.sendKeys(nr);
input.sendKeys(Keys.TAB);
$(NativeButtonElement.class).id(DebugWindowErrorHandlingView.CAUSE_ERRORS_ID).click();
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class PreserveOnRefreshIT method openingToAnotherPageWithSameComponents_should_preserveComponentWithoutChangedIdAttribute.
@Test
public void openingToAnotherPageWithSameComponents_should_preserveComponentWithoutChangedIdAttribute() {
/*
* Currently, when preserving exported components, they are identified
* by window name, component's tag, and generated id of the embedded web
* component or id of the wrapping element (if available). Since windows
* name does not necessarily change when page changes, and generated id
* is only defined by type of the web component and its order on the
* page, the component cannot be reliably identified uniquely. In order
* to assure uniqueness, the user must provide id for the component. If
* if is provided, the uniqueness can be assured between pages. Contents
* are synchronized between locations in two cases: - embedded element
* has the same id as its counter-part in the different location. -
* component does not have user-assigned id and has the same generated
* id on both locations (this happens, if the component has the same
* counted index within the component type between pages)
*/
final String TEXT_CONTENTS = "black cat";
TestBenchElement noIdElement = findTagWithoutId(PRESERVE_ON_REFRESH_TAG);
Assert.assertEquals(MODIFIED + " input should be empty", "", getValue(MODIFIED));
Assert.assertEquals(UNMODIFIED + " input should be empty", "", getValue(UNMODIFIED));
Assert.assertEquals("Input without id should be empty", "", getValue(noIdElement));
writeInInput(MODIFIED, TEXT_CONTENTS);
writeInInput(UNMODIFIED, TEXT_CONTENTS);
writeInInput(noIdElement, TEXT_CONTENTS);
relocateTo("preserveOnRefreshSecondary.html");
// same place, same id
Assert.assertEquals(MODIFIED + " input should have preserved state", TEXT_CONTENTS, getValue(MODIFIED));
// same place, different id
Assert.assertEquals(NEW_ID + " input should be empty", "", getValue(NEW_ID));
// same place, no assigned id
TestBenchElement noIdElement2 = findTagWithoutId(PRESERVE_ON_REFRESH_TAG);
Assert.assertEquals("Input without id should have preserved state", TEXT_CONTENTS, getValue(noIdElement2));
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class WebComponentIT method indexPageGetsThemedWebComponent_themeIsApplied.
@Test
public void indexPageGetsThemedWebComponent_themeIsApplied() {
open();
waitForElementVisible(By.tagName("themed-web-component"));
TestBenchElement webComponent = $("themed-web-component").first();
TestBenchElement themedComponent = webComponent.$("themed-component").first();
TestBenchElement content = themedComponent.$("div").first();
Assert.assertNotNull("The component which should use theme doesn't " + "contain elements", content);
Assert.assertEquals("rgba(255, 0, 0, 1)", content.getCssValue("color"));
}
Aggregations