@FindBy snafu

148 views
Skip to first unread message

Paul Hammant

unread,
Aug 12, 2018, 2:33:07 AM8/12/18
to selenium-developers


Lines 88-90: I've some Angular specific findbys (in https://github.com/paul-hammant/ngWebDriver) that work well when a single WebElement is found. But they do not work when it is List<WebElement>. I'm thinking because line 91 needs to be

    && field.getAnnotation(ByAngularModel.FindBy.class) == null

Can't do that of course for multiple reasons.

Java can't do inheritance for annotations with (@ByAngularModel.FindBy extends @FindBy) so there's no clean OO way of making that list of three more extendable

I wonder whether a name match would be enough - loop thru all annotations and treat any @FindBy in any package the same.

Thoughts?

- Paul

Simon Stewart

unread,
Aug 17, 2018, 1:13:40 PM8/17/18
to selenium-developers
This is the entire reason we say to people that the PageFactory is a good idea, but a terrible implementation. None of the things that people are bending it to do were really considered at the time I threw the code together. That class is riddled with bugs (notably, a list might well contain a subclass of WebElement, and a non-generic list can also contain WebElement instances)

I feel that maybe using a loop and guessing on class name is a damn risky thing to do. Better would be to accept a Predicate that abstracts this logic away, but then we're heading down the path of making this Not Awful.... :)

Cheers,

Simon

--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-developers/CA%2B298Ugm0YmqYEdHiAjdJJbv1yVM3cX%2Bs1OyBJUrQq2dLQEnxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Serguei Kouzmine

unread,
Oct 8, 2018, 5:56:35 PM10/8/18
to Selenium Developers
Hello Paul

Heinrih and mysef has created By's for my version of Protractor java client a while ago;


based on

IIRC it has been capable of grouping By sets 
(my port class  hierarchy is different from yours)

Serguei Kouzmien
Reply all
Reply to author
Forward
0 new messages