How to use apostrophe (') in xpath while finding element using webdriver?

后端 未结 5 515
难免孤独
难免孤独 2020-12-18 19:32

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

i need to use below Xpath expression

//         


        
5条回答
  •  情歌与酒
    2020-12-18 19:52

    You have to use double-quotes as your XPath string literal delimiter, since XPath 1.0 doesn't provide a way of escaping quotes. In addition to that, you can escape the double-quotes in Java, to avoid it from conflicting with your Java string delimiter, which also use double-quotes :

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

提交回复
热议问题