-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Feature
Copy link
Description
I have a TextField
added to a FormLayout
via formLayout.addFormItem(textField, "To")
. When call TextFieldElement.getLabel()
on it, it returns "". A FormLayoutElement
should be able to provide the label of the child component, e.g. via getChildLabel(Element element)
.
Implementations suggested by @TatuLund
@Element("vaadin-form-item")
public class FormItemElement extends TestBenchElement {
public WebElement getLabel() {
return findElements(By.xpath(".//*[@slot='label']")).stream()
.filter(element -> element.getAttribute("for") == null)
.findFirst().orElseThrow(() -> new IllegalArgumentException(
"No label element found in form item"));
}
public String getLabelText() {
return getLabel().getText();
}
public TestBenchElement getInput() {
String id = getLabel().getAttribute("id");
return $(TestBenchElement.class).attribute("aria-labelledby", id)
.first();
}
}
@Element("vaadin-form-layout")
public class FormLayoutElement extends TestBenchElement {
public List<FormItemElement> getFormItems() {
return $(FormItemElement.class).all();
}
public FormItemElement getFormItemByLabel(String label) {
return getFormItems().stream()
.filter(item -> item.getLabelText().equals(label)).findFirst()
.orElseThrow(() -> new IllegalArgumentException(
"No form item found with label: " + label));
}
}
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done / Pending Release