How FindBy annotation of Page Factory can be used in Selenium

0 votes
How @FindBy annotation of Page Factory can be used in Selenium?
Jul 4, 2019 in Selenium by Mridul
10,309 views

1 answer to this question.

0 votes

Hey Mridul, Page Factory uses annotation @FindBy to identify Web Elements in the page. The @FindBy annotation supports all the locators that we use to find a web element i.e.:
id, name, className, css, xpath, tagName, linkText and partialLinkText

We can use @FindBy annotation either by specifying both "How" and "using" or by specifying any one of the locators (eg. id):

@FindBy(how = How.ID, using = "username")
private WebElement username;

OR

@FindBy(id="username")
private WebElement userName;

OR

@FindBy(className=".input.username")
private WebElement username;
answered Jul 4, 2019 by Anvi
• 14,150 points

Related Questions In Selenium

0 votes
1 answer

How can Custom Firefox Profiles be created and used in Selenium?

Hi Vijay, to create Custom Firefox Profile ...READ MORE

answered May 24, 2019 in Selenium by Abha
• 28,140 points
1,202 views
0 votes
1 answer
0 votes
1 answer

How page synchronization can be achieved in Selenium WebDriver?

Hey Dhvani, Page Synchronization can be achieved ...READ MORE

answered May 28, 2019 in Selenium by Ujjwal
3,214 views
0 votes
1 answer

How @Listener annotation can be used in TestNG?

Hey Barkha, TestNG @listeners are used to configure reports ...READ MORE

answered Jun 10, 2019 in Selenium by Abha
• 28,140 points
1,618 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,673 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,142 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,221 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,874 views
0 votes
1 answer

How selenium can be used in devops lifecycle?

Hey Catherine, as we know that a ...READ MORE

answered May 8, 2019 in Selenium by Anvi
• 14,150 points
1,869 views
0 votes
1 answer

Can anyone demonstrate how navigation commands can be used on a webpage in Selenium?

Hey Amanprit, Navigation Commands are used to ...READ MORE

answered Jul 5, 2019 in Selenium by Anvi
• 14,150 points
650 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP