I came up in a situation where I have to identify an using and my element starts with ('). I will give the example below.

This is the usual way we 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?

Source link https://sqa.stackexchange.com/questions/26341/how-to-write-xpath-if-i-have-apostrophe-in-my-xpath-element


Please enter your comment!
Please enter your name here