I am trying to pass the value below in a script using the Javascript executor.
String value = "ac.saveDocket('CompanyRegistration','https://yyy.yyy',0);"
JavascriptExecutor executor = ((driver) as JavascriptExecutor)
WebElement webElement = driver.findElement(By.xpath("//div[@class=\'CodeMirror-code\']/div[1]//pre"))
executor.executeScript("arguments[0].innerHTML='$value';", webElement)
An error occurs when running this:
org.openqa.selenium.JavascriptException: javascript error: Unexpected identifier
The execution is successful without special characters, so it appears that the issue lies with the single quotes.
Is there a way to successfully pass special characters like single quotes to the JavaScript executor?