I am trying to pass value to a calendar field using JavascriptExecutor
in my Selenium code.
The method declaration is as follows:
public static void selectDepDate(WebDriver driver, String value) { js = (JavascriptExecutor) driver; js.executeScript("arguments[0].removeAttribute('readonly', 0)", deptDate); js.executeScript("arguments[0].value=''", deptDate); js.executeScript("arguments[0].value='" + value + "')", deptDate); }
I am calling the method via selectDepDate(driver, "15-Sep-2020")
.
Upon execution of the script, I am seeing the following exception in the console logs:
Exception in thread "main" org.openqa.selenium.JavascriptException: javascript error: Unexpected token ')'