Pull Request 62 - Add a @FindAll annotation to the Java Page Factory

294 views
Skip to first unread message

Mark Collin

unread,
May 15, 2013, 10:53:17 AM5/15/13
to selenium-...@googlegroups.com
I've been hassling about this in IRC for a while and haven't got a direct answer either way yet, so I though I'd ping something over to the dev list.

https://github.com/SeleniumHQ/selenium/pull/62

I've added a @FindAll annotation to the Java Page Factory, this does the following:

The @FindAll annotation will take all the elements found by the various @FindBy annotations it encompasses and then returns them all in one list. Obviously only the first WebElement in the list is returned if you are populating a WebElement instead of a List. The syntax would look like this when loading it into a WebElement:

@FindAll({
    @FindBy(id = "cheese"),
    @FindBy(id = "crackers")
})
public WebElement cheeseAndCrackers;

Or loading into a List of WebElement's

@FindAll({
    @FindBy(id = "cheese"),
    @FindBy(id = "crackers")
})
public List<WebElement> cheeseAndCrackers;

It could also have been called @FindAny (and I'm happy to change it to that if you think is sounds more descriptive, however @FindAny doesn't sound very deterministic, it kind of implies that you may get any element, whereas the way the elements is found is deterministic).

It is different to the existing @FindBys annotation.
The @FindBys annotation will find the first @FindBy annotation and then try to find the second @FindBy annotation as a child of the first one, so it really does:

driver.findElement(<By_FindByA>).findElement(<By_FindByB>).


Is this in a state where you would be happy to see it added to the code base or does it need to be tweaked?
Reply all
Reply to author
Forward
0 new messages