Search in sources :

Example 1 with CheckBox

use of ru.yandex.qatools.htmlelements.element.CheckBox in project page-factory-2 by sbtqa.

the class HTMLPage method setCheckBox.

/**
 * Find web element with corresponding title, if it is a check box, select
 * it If it's a WebElement instance, check whether it is already selected,
 * and click if it's not Add corresponding parameter to allure report
 *
 * @param elementTitle WebElement that is supposed to represent checkbox
 *
 * @throws PageException if page was not initialized, or required element
 *                                                           couldn't be found
 */
@ActionTitle("ru.sbtqa.tag.pagefactory.select.checkBox")
public void setCheckBox(String elementTitle) throws PageException {
    WebElement targetElement = getElementByTitle(this, elementTitle);
    if (targetElement.getClass().isAssignableFrom(CheckBox.class)) {
        ((CheckBox) targetElement).select();
    } else {
        setCheckBoxState(targetElement, true);
    }
    ParamsHelper.addParam(elementTitle, " is checked");
}
Also used : CheckBox(ru.yandex.qatools.htmlelements.element.CheckBox) WebElement(org.openqa.selenium.WebElement) ActionTitle(ru.sbtqa.tag.pagefactory.annotations.ActionTitle)

Example 2 with CheckBox

use of ru.yandex.qatools.htmlelements.element.CheckBox in project page-factory-2 by sbtqa.

the class HtmlStepsImpl method setFormElementValue.

public T setFormElementValue(String key, String value) {
    WebElement element = getElement(key);
    if (element instanceof TextInput) {
        element.clear();
        element.sendKeys(value);
    } else {
        if (element instanceof SelectValue) {
            ((SelectValue) element).selectByValue(value);
        } else {
            if (element instanceof CheckBox) {
                ((CheckBox) element).set(Boolean.valueOf(value));
            } else {
                throw new AutotestError("Incorrect element type: " + key);
            }
        }
    }
    return (T) this;
}
Also used : AutotestError(ru.sbtqa.tag.qautils.errors.AutotestError) CheckBox(ru.yandex.qatools.htmlelements.element.CheckBox) WebElement(org.openqa.selenium.WebElement) HtmlElementUtils.getWebElement(ru.sbtqa.tag.pagefactory.utils.HtmlElementUtils.getWebElement) TextInput(ru.yandex.qatools.htmlelements.element.TextInput) SelectValue(ru.sbtqa.tag.pagefactory.elements.select.SelectValue)

Aggregations

WebElement (org.openqa.selenium.WebElement)2 CheckBox (ru.yandex.qatools.htmlelements.element.CheckBox)2 ActionTitle (ru.sbtqa.tag.pagefactory.annotations.ActionTitle)1 SelectValue (ru.sbtqa.tag.pagefactory.elements.select.SelectValue)1 HtmlElementUtils.getWebElement (ru.sbtqa.tag.pagefactory.utils.HtmlElementUtils.getWebElement)1 AutotestError (ru.sbtqa.tag.qautils.errors.AutotestError)1 TextInput (ru.yandex.qatools.htmlelements.element.TextInput)1