我需要在我的 xpath 表达式中使用撇号 ('),我需要使用它来使用 webdriver 查找元素
我需要使用下面的 Xpath 表达式
//input[@text="WE'd like to hear from you"]
在查找元素函数中使用上述表达式时,我将双引号替换为单引号
driver.findelements(By.xpath("//input[@text='WE'd like to hear from you']"))
最佳答案
使用 xpath 如下所示:
driver.findElements(By.xpath("//input[contains(@text,\"WE'd\")]"));
希望这对您有所帮助。
关于java - 使用 webdriver 查找元素时如何在 xpath 中使用撇号 (')?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37542773/