本文介绍了如何在使用webdriver查找元素时在xpath中使用撇号(')?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的xpath表达式中使用撇号('),我需要使用webdriver来查找元素

I need to use apostrophe (') in my xpath expression which i need to use in finding elements using webdriver

我需要在Xpath表达式下面使用

i need to use below Xpath expression

//input[@text="WE'd like to hear from you"]

在find元素函数中使用上面的表达式时,我用单引号替换双引号

while using the above expression in find elements function i am replacing double quotes with single quotes

driver.findelements(By.xpath("//input[@text='WE'd like to hear from you']"))


推荐答案

使用xpath,如下所示:

Use the xpath as shown below:

driver.findElements(By.xpath("//input[contains(@text,\"WE'd\")]"));

希望这会有所帮助。

这篇关于如何在使用webdriver查找元素时在xpath中使用撇号(')?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 02:35