Software Development and QA Tips By QASource Experts

How FindBy Works in Selenium?

Written by Timothy Joseph | Aug 16, 2021 4:00:00 PM

The @FindBy explanation is utilized in Selenium Page Objects mechanization tests to indicate the area for a WebElement or a rundown of WebElements.


Utilizing the PageFactory, these WebElements are generally instated when a Page Object is made and can be used to find web components that utilize various methodologies like ID, XPath and CSSelector.

There are two different ways to utilize this comment:

1. Start by indicating both 'How' and 'Utilizing' under FindBy comment.

@FindBy(how = How.ID, utilizing = "elementID")

WebElement username;

2. By directly utilizing a finder like id, XPath, ClassName, partialLinkText, tagName or name.

@FindBy(id="elementID")
@FindBy(id="elementID")

WebElement username;

The above comments are broadly utilized in test structures made via computerization testing organizations. If you want professional assistance in using Selenium webdriver, contact QASource today