Search in sources :

Example 6 with TestBenchElement

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

the class UploadIT method multiFileUpload.

@Test
@Ignore
public void multiFileUpload() throws Exception {
    open();
    waitUntil(driver -> {
        By selector = By.id(UPLOAD_ID);
        return isElementPresent(selector) && findElement(selector).isDisplayed();
    });
    File tempFile = createTempFile("foo");
    TestBenchElement input = $(TestBenchElement.class).id(UPLOAD_ID).$(TestBenchElement.class).id("fileInput");
    setLocalFileDetector(input);
    input.sendKeys(tempFile.getPath());
    waitUntil(driver -> isElementPresent(By.className("uploaded-text")));
    WebElement uploadedText = findElement(By.className("uploaded-text"));
    Assert.assertEquals("foo", uploadedText.getText());
}
Also used : By(org.openqa.selenium.By) WebElement(org.openqa.selenium.WebElement) RemoteWebElement(org.openqa.selenium.remote.RemoteWebElement) File(java.io.File) TestBenchElement(com.vaadin.testbench.TestBenchElement) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with TestBenchElement

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

the class ComponentAddedViaInitListenerIT method componentAddedViaInitListenerIsLoaded.

@Test
public void componentAddedViaInitListenerIsLoaded() {
    open();
    TestBenchElement component = $("init-listener-component").first();
    TestBenchElement div = component.$("div").first();
    Assert.assertEquals("Init Listener Component", div.getText());
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test)

Example 8 with TestBenchElement

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

the class ParentTemplateIT method customElementIsRegistered.

@Test
public void customElementIsRegistered() throws Exception {
    open();
    TestBenchElement template = $("parent-template").first();
    TestBenchElement div = template.$("*").id("div");
    Assert.assertEquals("baz", div.getText());
    TestBenchElement child = template.$("*").id("child");
    Assert.assertEquals("bar", child.$("*").id("info").getText());
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test)

Example 9 with TestBenchElement

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

the class TemplatePushIT method execJsPushed.

@Test
public void execJsPushed() throws Exception {
    open();
    TestBenchElement tpl = $("template-push-view").first();
    tpl.$("button").id("execJsTest").click();
    TestBenchElement label = tpl.$("label").id("label");
    waitUntil(foo -> {
        return "from execJS".equals(label.getText());
    }, 5);
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test)

Example 10 with TestBenchElement

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

the class AppViewIT method upload_file_in_private_view.

@Test
public void upload_file_in_private_view() throws IOException {
    open("private");
    loginUser();
    UploadElement upload = $(UploadElement.class).first();
    File tmpFile = File.createTempFile("security-flow-image", ".png");
    InputStream imageStream = getClass().getClassLoader().getResourceAsStream("image.png");
    IOUtils.copyLarge(imageStream, new FileOutputStream(tmpFile));
    tmpFile.deleteOnExit();
    upload.upload(tmpFile);
    TestBenchElement text = $("p").id("uploadText");
    TestBenchElement img = $("img").id("uploadImage");
    Assert.assertEquals("Loan application uploaded by John the User", text.getText());
    Assert.assertTrue(img.getPropertyString("src").contains("/VAADIN/dynamic/resource/"));
}
Also used : InputStream(java.io.InputStream) UploadElement(com.vaadin.flow.component.upload.testbench.UploadElement) FileOutputStream(java.io.FileOutputStream) File(java.io.File) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test)

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