Directory

← Back

Selenium Addon for Vaadin

Selenium Addon for Vaadin

Author

Rating

Popularity

<100

Selenium addon for Vaadin

Selenium utilities to test Vaadin applications.

It supports an abstraction layer to easily read / write and assert value inside fields. Currently supported fields are:

  • CheckBox
  • Date
  • DropDown
  • OptionGroup
  • Text
  • TextArea To use it, use the InputMethodFactory to get a InputMethod for the elemenent you want to access.

It supports automatically filling / validation of forms with values from a property file (see DataDriven* classes). It has an utility to handle the often occuring StaleElementReferenceException (SaveElementAccess) It contains a class WaitConditions to wait for vaadin background ajax calls to finsh or to wait for specific conditions. Its base SeleniumTest class has a driver enhancement to take a screenshot when a test fails. The base Page Object (BasePO) has all these utils initialized and bound together.

It is configured by a property file named env.properties: url: The url of the main page of your vaadin app to test remote: (TRUE / FALSE) If you use a selenium server, set this to true. It will then use the remote driver seleniumGrid: The URL of the selenium server SAUCE_ONDEMAND_ACCESS_KEY: If testing with sauce labs, this holds the access key SAUCE_ONDEMAND_USERNAME: If testing with sauce labs, this holds the username

Additionally it supports the ConfirmDialog from the vaadin addon with an own ConfirmDialogPO.

Vaadin 7.1 is currently not supported, there are problems with the Date field. See message https://vaadin.com/forum#!/thread/3689227.

Sample code

InputMethod inputMethod = new InputMethodFactory(driver); // driver is the selenium WebDriver

// Read value
String elementValue = inputMethod.get("id_of_element");

// Set new value
inputMethod.input("id_of_element", "new value");

// Assert
inputMethod.assertInput("id_of_element", "new value");
url = http://localhost:8080/vaadin/app/
remote = FALSE
package org.vaadin.addons.javaee.selenium.examples;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.vaadin.addons.javaee.selenium.po.BasePO;
import org.vaadin.addons.javaee.selenium.WaitConditions;

public class CustomerNewPO extends BasePO {

    private static final String ADDRESS_CITY = "address.city";

    private static final String ADDRESS_ZIP = "address.zip";

    private static final String ENTITY = "Customer";

    public CustomerNewPO(WebDriver driver) {
        super(driver);
    }

    @Override
    protected String getIdentifyingElement() {
        return "CustomerNewPanel";
    }

    public CustomerOverviewPO createCustomer() {
        dataActions.setDefaultValues(ENTITY, null);
        actions.clickButton("button_save");
        return new CustomerOverviewPO(driver);
    }

    public CustomerOverviewPO createCustomerWithLastName(String lastName) {
        dataActions.setDefaultValues(ENTITY, "woLastName");
        actions.input(ENTITY, "lastName", lastName);
        actions.clickButton("button_save");
        return new CustomerOverviewPO(driver);
    }

    public void setCity(String city) {
        actions.input(ENTITY, ADDRESS_CITY, city);
        WebElement zipField = driver.findElement(By.id(ENTITY + "." + ADDRESS_ZIP));
        zipField.click();
    }

    public void setZip(String zip) {
        actions.input(ENTITY, ADDRESS_ZIP, zip);
        WebElement cityField = driver.findElement(By.id(ENTITY + "." + ADDRESS_CITY));
        cityField.click();
    }

    public void assertZip(String zip) {
        WaitConditions.waitForVaadin(driver);
        assertions.assertText(ENTITY, ADDRESS_ZIP, zip);
    }

    public void assertCity(String city) {
        WaitConditions.waitForVaadin(driver);
        assertions.assertText(ENTITY, ADDRESS_CITY, city);
    }

}
package org.vaadin.addons.javaee.selenium.examples;

import org.junit.Test;
import org.vaadin.addons.javaee.selenium.SeleniumTest;

public class CustomerNewTest extends SeleniumTest {

    @Test
    public void createNewCustomer() {
        CustomerNewPO customerNewPO = navigateToCustomerNew();
        CustomerOverviewPO overviewPO = customerNewPO.createCustomer();
        overviewPO.assertCustomer();
    }

    @Test
    public void populateZipByCity() {
        CustomerNewPO customerNewPO = navigateToCustomerNew();
        customerNewPO.setCity("Munich");
        customerNewPO.assertZip("80000");
    }

    @Test
    public void populateCityByZip() {
        CustomerNewPO customerNewPO = navigateToCustomerNew();
        customerNewPO.setZip("80000");
        customerNewPO.assertCity("Munich");
    }

    private CustomerNewPO navigateToCustomerNew() {
        // Dummie
        return null;
    }

}
src/test/resources/Customer.properties:
firstName=Thomas
lastName=Letsch

src/test/resources/Customer_woLastName.properties:
firstName=Thomas

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Moved classes to src/main/java to better support maven dependency resolution. Added example test and PO.

Released
2013-07-28
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 7.0
Browser
N/A

Selenium Addon for Vaadin - Vaadin Add-on Directory

Selenium Addon for Vaadin Selenium Addon for Vaadin - Vaadin Add-on Directory
Selenium addon for Vaadin ============== Selenium utilities to test Vaadin applications. It supports an abstraction layer to easily read / write and assert value inside fields. Currently supported fields are: - CheckBox - Date - DropDown - OptionGroup - Text - TextArea To use it, use the InputMethodFactory to get a InputMethod for the elemenent you want to access. It supports automatically filling / validation of forms with values from a property file (see DataDriven* classes). It has an utility to handle the often occuring StaleElementReferenceException (SaveElementAccess) It contains a class WaitConditions to wait for vaadin background ajax calls to finsh or to wait for specific conditions. Its base SeleniumTest class has a driver enhancement to take a screenshot when a test fails. The base Page Object (BasePO) has all these utils initialized and bound together. It is configured by a property file named env.properties: url: The url of the main page of your vaadin app to test remote: (TRUE / FALSE) If you use a selenium server, set this to true. It will then use the remote driver seleniumGrid: The URL of the selenium server SAUCE_ONDEMAND_ACCESS_KEY: If testing with sauce labs, this holds the access key SAUCE_ONDEMAND_USERNAME: If testing with sauce labs, this holds the username Additionally it supports the ConfirmDialog from the vaadin addon with an own ConfirmDialogPO. Vaadin 7.1 is currently not supported, there are problems with the Date field. See message https://vaadin.com/forum#!/thread/3689227.
Author Homepage
Issue Tracker
Source Code

Selenium Addon for Vaadin version 1.0.1-SNAPSHOT
Moved classes to src/main/java to better support maven dependency resolution. Added example test and PO.

Online