Last active
November 1, 2023 12:26
-
-
Save SarahElson/5cdc25fbc7b3f9a1245fb8807e51c3b6 to your computer and use it in GitHub Desktop.
How to Use @findby Annotation in Selenium Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyAccountPage { | |
public MyAccountPage(final WebDriver driver) { | |
PageFactory.initElements(driver, this); | |
} | |
@FindBy(css = "#content > div:nth-child(1) h2") | |
@CacheLookup | |
private WebElement myAccountTitle; | |
public String getMyAccountPageTitle() { | |
return this.myAccountTitle.getText(); | |
} | |
@FindAll({ | |
@FindBy(how = How.LINK_TEXT, using = "Logout"), | |
@FindBy(how = How.CSS, using = "#column-right > div > a:nth-child(14)") | |
}) | |
private WebElement logoutLink; | |
public void logoutFromEcommercePlayground() { | |
this.logoutLink.click(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment