Search in sources :

Example 1 with XPathBuilder

use of org.activityinfo.test.pageobject.api.XPathBuilder in project activityinfo by bedatadriven.

the class BsFormPanel method findFieldsByLabel.

/**
 * Useful for repeating subforms where we may have many fields with the same label.
 *
 * @param labelText label text
 * @return all fields by label
 */
public List<BsField> findFieldsByLabel(String labelText) {
    List<BsField> result = Lists.newArrayList();
    XPathBuilder div = form.find().label(withText(labelText)).ancestor().div(withClass("form-group"));
    if (div.firstIfPresent().isPresent()) {
        for (FluentElement element : div.waitForList().list()) {
            result.add(new BsField(element));
        }
        return result;
    }
    XPathBuilder label = form.find().label(withText(labelText)).ancestor().span(withClass("radio"));
    if (label.firstIfPresent().isPresent()) {
        for (FluentElement element : label.waitForList().list()) {
            result.add(new BsField(element));
        }
    }
    return result;
}
Also used : FluentElement(org.activityinfo.test.pageobject.api.FluentElement) XPathBuilder(org.activityinfo.test.pageobject.api.XPathBuilder)

Aggregations

FluentElement (org.activityinfo.test.pageobject.api.FluentElement)1 XPathBuilder (org.activityinfo.test.pageobject.api.XPathBuilder)1