I came up in a situation where I have to identify an element using XPath and my element starts with apostrophe (')
. I will give the example below.
This is the usual way we write some XPath
.
By identifier = By.xpath("//span[@trans='WbOrderHeader.OneCancelsAnother']");
In the above code after that equals we write the WbOrderHeader.OneCancelsAnother
inside the apostrophe. but what if my identifier starts with an apostrophe?
for example, the same code will be like this
By identifier = By.xpath("//span[@trans=''WbOrderHeader.OneCancelsAnother']");
so the identifier will be WbOrderHeader.OneCancelsAnother
There is one apostrophe (')
at the beginning and there is none at the end. In this case, when I write the XPath the way I wrote here, it's not identifying. How can I solve this problem?
How to write XPath in this kind of situation?
'
the single quote.