Reputation: 697
The first xpath is working whereas the second not:
First:
"//*[@id='j_idt46:j_username']";
Second:
"//*[contains(@id,'username']";
Why?
Upvotes: 1
Views: 62
Reputation: 32036
To what could be figured out of the information provided, the way you are using contains is possibly inappropriate :
As mentioned by @TuringTux - //*[contains(@id,'username')]
could be the possible change if the same lined goes as it is in your code.
Also a good practice to follow in //*[contains(@id,'username')]
, would be to replace *
by an element type in html.
And lastly there could be chances when you are trying to access elements using //*[contains(@id,'username')]
, you may be ending up getting a list of these similar WebElements while you might be trying to access only a single at the same time.
Upvotes: 2