Reputation: 16
Apologies if this question has already been asked / answered.
I'm keen to automate a date picker by removing the readonly attribute on the field and passing the date directly into it.
I know this is possible with Selenium, iMacros and other similar tools. For Example here:
@Test
public void CalendarTest()
{
WebDriver driver= new FirefoxDriver();
// Creating JavascriptExecutor interface object Type casting
JavascriptExecutor js = (JavascriptExecutor)driver;
// Launching the Site. driver.get("http://keenthemes.com/preview/metronic/theme/admin_1/components_date_time_pickers.html");
WebElement datePicker = driver.findElement(By.xpath("(//input[@class='form-control'])[11]"));
// Need to remove readonly HTML attribute
js.executeScript("document.getElementsByClassName('form-control')[11].removeAttribute('readonly');", datePicker);
// Enter Date directly into the field
driver.findElement(By.xpath("(//input[@class='form-control'])[11]")).sendKeys("03-05-2019");
}
However, cannot achieve the same result in Gauge/Taiko using JavaScript.
I'm relatively new to Taiko, so any help is greatly appreciated.
Upvotes: 0
Views: 446
Reputation: 16
The following appears to be working in my case:
evaluate(textBox({name:"fieldName"}), (element) => element.setAttribute("value", "01-01-2020"))
Upvotes: 0