jmreicha jmreicha - 24 days ago 12
Javascript Question

How to nest these quotes?

I am trying to get the following code to work using nested quotes but I don't know how to triple nest them. Here's the code I have so far but it isn't working, I get

Runtime.evaluate threw exception: SyntaxError: Unexpected token &
when I run it.

driver.executeScript("$("li[data-drilldown='interests']").click()")


It seems like there should be a better way to do this but I'm not familiar enough with Javascript

Answer

Just escape them:

driver.executeScript("$(\"li[data-drilldown='interests']\").click()");
Comments