I have searched the Selenium Webdriver APi docs hosted on google code. Currently using the PageFactory to initlize my Page objects, but having issue initilizing a list of WebElement.
What I need is a way to initialize a list of elements, ideally a list of drop-down select boxes.
I have looked at the API references to @Findsby and @ByChained but still can not figure out the best way to initlize a list of dropdown select boxes. I COULD have a seperate WebElement for each one and grab the ID but I would like to initlize a list of List selects
public class PageObject {
@FindBy(id="element_id")
private WebElement element;
public getElement() {
return element;
}
}
public class PageObject {
@FindBys(className="selectItmes")
private List<WebElement> selects;
public List<WebElement> getSelects() {
return selects;
}
}
Or must I use a single Web Element for each element? :(
Anyone know how to use the PageFactory and initlize a List elements; using the FindsBy annotation. I can't find any way of doing this yet there are google issues on the selenium google docs site saying this has been fixed in the Java api bindings and in version 2.12 as it was mistaken disabled in 2.11.... I still can't initialize a list. =/
This feature has been recently added in Selenium 2.0. Check this issue. It is fixed now.
From the documents, you could do something like,
@FindAllBy(className="selectItmes")
List<WebElement> selects;
If you are interested in the code, check this out
Here is standard solution what I do in our test framework, until @FindAllBy doesn't work in Selenium library:
private List<WebElement> selects;
public List<WebElement> getSelects() {
selects = getDriver().findElements(By.xpath("..."));
return selects;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With