Reputation: 1541
Whenever I copy an element's XPath and then paste it into my Java IDE (IntelliJ), backslashes are added to the XPath - why is this?
For example, IntelliJ automatically changes
//*[@id="SearchForm:FirstName"]
to
//*[@id=\"SearchForm:FirstName\"]"
Upvotes: 1
Views: 428
Reputation: 111541
It's not Java per se but your IDE that's doing this for you, because otherwise
"//*[@id="SearchForm:FirstName"]"
would be interpreted as
"//*[@id="
[junk after end of string resulting in a syntax error]So it escapes the embedded quotes for you:
"//*[@id=\"SearchForm:FirstName\"]"
If you don't like this, you can use single quotes:
"//*[@id='SearchForm:FirstName']"
Upvotes: 2