Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


In the below article I will show the process of enabling the Eclipse feature which will automatically escape double quotes when pasting into a string literal.


When copying Xpath XPath from the Perfecto Object Spy you are copying Xpath XPath which surrounds string values with double quotes (").


Example: //*[@text="Login"]


And when pasting the Xpath XPath into Java code you must manually change the double quotes to either single quotes or escape the double quotes.


//*[@text='Login'] or //*[@text=\"Login\"]


Eclipse has a built in feature that will automatically escape double quote characters if it knows you are pasting the string inside of double quotes which are already present in the code editor.


For instance you can paste this: //*[@text="Login"]


Into this: driver.findElemementByXpath("");


And you will end up with this: driver.findElemementByXpath("//*[@text=\"Login\"]");


However if you paste into this: driver.findElementByXpath(); without the double quotes you simply end up with this: driver.findElemementByXpath(//*[@text="Login"]);. So make sure you are always pasting into "".


To enable this setting first go to Windows→Preferences

Next expand Java->Editor->Click on Typing

Check the box that says Escape text when pasting into a string literal