I am porting over an existing project and I have a super class called DetailPage
that is the only thing I can change/edit. It's a selenium testing project and in previous versions I had hundreds of individual pages that extended DetailPage
and had the following lines:
@FindBy(id="someID")
private WebElement someIDBox;
to search a page for a given id and assign that element to a variable. I now have a similar website that is nonW3C
so instead of finding by id
I now need to find by name
ie:
@FindBy(name="someID")
private WebElement someIDBox;
is what I now want.
So my question is how can I (if possible) make a super class function in DetailPage that would notice I say id
and override with name
?
I DO NOT want a function that just replaces the text id
with name
in the individual pages as I need to preserve those.
This does not meet the criteria that I asked but thanks to @guy I was introduced to ByIdOrName which helps with my problem. So I made a little script that went through all my files in the workspace and replaced
@FindBy(id="someID")
private WebElement someIDBox;
with
@FindBy(how = How.ID_OR_NAME, using="someID")
private WebElement someIDBox;
while this made it so I had to alter all test pages(which is what I wanted to avoid) it does not alter how other tests for other websites work which is key!