Java – how to use apostrophe (‘) in XPath when using webdriver to find elements?
•
Java
I need to use an apostrophe (') in my XPath expression, and I need to use it when using webdriver to find elements
I need to use it under an XPath expression
//input[@text="WE'd like to hear from you"]
When using the above expression in the find element function, I replace double quotes with single quotes
driver.findelements(By.xpath("//input[@text='WE'd like to hear from you']"))
Solution
Use XPath as follows:
driver.findElements(By.xpath("//input[contains(@text,\"WE'd\")]"));
I hope this will help
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码