I have place the locator in properties file like :
header.navigation.product.link = //div[contains(@class,'grid-')]//li/a[contains(.,'%s')]
and while I'm using this locator in my code-
String headerproductlink = String.format(ConfigurationManager.getBundle()
.getString("header.navigation.category.link"), category)
And category = Women's Gym Clothing
While I'm trying to locate the element it unable to find.
even i have tried as Women\'s Gym Clothing
but no success.
Can someone please suggest a way ?
Below different ways worked for me:
Locator in Property file:
Java code:
Below also worked fine
Locator in Property file:
Java code:
Or Locator in Property file:
Java code:
In XPath 1.0 you can use either single quotes or double quotes to delimit a string literal, and you can use the other kinds of quotes to represent itself within the string. You can't have a string literal containing both single and double quotes, but you can use concat() to get around this limitation:
The situation is complicated if the XPath expression appears within a host language that imposes its own constraints; in that case any quotes within the XPath expression must be escaped using host language conventions, for example
\"
in Java,"
in XML.