0

@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

zara
  • 99
  • 1
  • 8
  • 3
    In the first option `linkText` , your text is wrapped in `[ ]` but not when using the XPath. Check the first option without `[` and `]` – supputuri Sep 24 '20 at 01:25
  • I tried with and without the[] but still not working. – zara Sep 24 '20 at 14:06

1 Answers1

1

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

Justin Lambert
  • 940
  • 1
  • 7
  • 13
  • There's only one element with "Enter Country". I believe this maybe the case of xapth being unique identifier for some elements. Thanks – zara Sep 24 '20 at 14:07