8

For Example:

By.xpath("//*[@id="ext-gen1035"]/div/div[3]/i")
har07
  • 86,209
  • 12
  • 77
  • 125
Prabhu
  • 117
  • 1
  • 2
  • 11
  • 1
    Possible duplicate of [How to escape single quote in xpath 1.0 in selenium for python](http://stackoverflow.com/questions/32759318/how-to-escape-single-quote-in-xpath-1-0-in-selenium-for-python) – Philipp Apr 07 '16 at 16:00
  • Also related : [Appium xpath escaping apostrophes](http://stackoverflow.com/questions/30778287/appium-xpath-escaping-apostrophes/30778431#30778431) – har07 Apr 08 '16 at 00:33

1 Answers1

11

You can actually use single quotes too:

By.xpath("//*[@id='ext-gen1035']/div/div[3]/i")

Or escape double quotes with a backslash:

By.xpath("//*[@id=\"ext-gen1035\"]/div/div[3]/i")
alecxe
  • 441,113
  • 110
  • 1,021
  • 1,148
  • Escaping with backslashes was apparently (according to https://stackoverflow.com/a/32759467/140707) only introduced in XPath 2.0, which still doesn't have wide adoption. – Frans Feb 23 '22 at 11:25