cz.datalite.webdriver.components.InputElement Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of Selenium Show documentation
                Show all versions of Selenium Show documentation
Integration tests with Selenium 2.0 (WebDriver) - PageObjects pattern (still in beta)
                
             The newest version!
        
        package cz.datalite.webdriver.components;
import org.openqa.selenium.WebElement;
/**
 * This parent class defines that the component can be part of form.
 * It means that there are methods for filling, clearing and getting values.
 * These components can be filled by special methods or by autofill. Autofill
 * writes to the component some constant valid data.
 *
 * @author Karel Cemus
 */
public abstract class InputElement extends ZkElement {
    public InputElement( final ZkElement parent, final WebElement webElement ) {
        super( parent, webElement );
    }
    /**
     * The component is filled with some valid data which means
     * allows to form to autofill all components. 
     *
     *
     * Every component has different type of data as valid
     * and some components has to do a selection from the list.
     * Due to very different implementations this is abstract method.
     * There is no general solution.
     */
    public abstract void autoFill();
    /**
     * Sends keys to the component. This is usable only on components
     * which can be filled from keyboard.
     * @param value string which is written to the component
     */
    public void write( final String value ) {
        clear();
        webElement.sendKeys( value );
    }
    /**
     * Clears the value in the component
     */
    public void clear() {
        webElement.clear();
    }
    /**
     * Returns value written or selected in the component
     * (if the component contains value attribute, it returns it's value, otherwise getText())
     * @return value of component
     */
    public String getValue() {
        if (webElement.getAttribute("value") != null)
            return webElement.getAttribute("value");
        else
            return webElement.getText();
    }
}
    © 2015 - 2025 Weber Informatics LLC | Privacy Policy