zara
zara

Reputation: 99

@FindBy using xpath vs linkText

@FindBy(linkText= "[Enter Country]") WebElement enterCountryMenu1;
@FindBy(xpath="//a[text()='Enter Country']") WebElement enterCountryMenu2;

This is just for my knowledge, why does the script work if I click the link by xpath element but not with linkText element? Does linkText require anything else? I make sure I comment out the first element before testing the second one.

Thanks in advance

Upvotes: 0

Views: 587

Answers (1)

Justin Lambert
Justin Lambert

Reputation: 978

xpath is unique web element identifier some element cant be identify id but can be idetify by xpath and also you can have other links with name Enter country

Upvotes: 1

Related Questions