FindBy is quite hard-coded at the moment to only support static
values. If you want to use dynamic locators with the FindBy
annotation, you will need to implement your own @DynamicFindBy
annotation which does the looking up. You may need to extend or
re-implement the PageFactory class - I don't know how extensible it
is, but it's not a huge amount of code or too complex. You may just
need to implement a new FieldDecorator and/or ElementLocator. Have a
look at $TRUNK/java/client/src/org/openqa/selenium/support/{PageFactory.java,
pagefactory/*.java} to see how it currently works. Unfortunately, I'm
not familiar enough with Java annotations to be more help without
reading up a bit more.
If you do do this, we'd be very happy to accept patches which make our
code more general and extensible :)
Don’t use a property file, but set the locators in the annotation.
The @FindBy annotation doesn’t support the use of variables.
Somebody was trying to write something to get around this a while back, but I don’t think he ever completed it:
https://groups.google.com/d/topic/webdriver/awxOw0FoiYU/discussion
From: webd...@googlegroups.com [mailto:webd...@googlegroups.com] On Behalf Of Julie
Sent: 15 October 2012 12:29
To: webd...@googlegroups.com
Subject: [webdriver] Re: Reading Xpaths from Properties File...
Hi Bharath,
Have you solved this problem?
I am having the same problem, I want the ids, xpaths and so on to be loaded from some properties file but Java gives me
"the value for annotation must be a constant expression"
@FindBy(how = How.XPATH, using = propertiesFile.getValueForKey(A))
public WebElement termsAndConditionsLink;
Could you please help ?
--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/e_hTgztpUh0J.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.