我想通过JavaScript Executor在Selenium Webdriver中选择日期。
webDriver.get("https://www.spicejet.com/");
WebElement date = webDriver.findElement(By.id("ctl00_mainContent_view_date1"));
String dateVal = "20-10";
selectDateByJS(webDriver, date, dateVal);
}
public static void selectDateByJS(WebDriver webDriver, WebElement element, String dateVal) {
JavascriptExecutor js = ((JavascriptExecutor) webDriver);
js.executeScript("argument[0].setAttribute('value','" + dateVal + "');", element);
}