问题
Here is a working solution for choosing a date from a datepicker using robot framework. Datepickers are basically input tags but some of them have an extra attribute "readonly" due to which it becomes difficult to add date into it.
1)First Check if datepicker is readonly or not. -inspect the page , locate the tag and check. if it is not read only we can directly use the below code to under previous day date.
${Yeterday_Date} = Get Current Date result_format=%d/%m/%Y increment=-1 day
Input Text ${locator} ${Yeterday_Date}
2)If it has an attribute readonly, remove that attribute and input date into it.
Execute Javascript document.querySelector("locator").removeAttribute("readonly");
Execute Javascript document.querySelector("locator").removeAttribute("onchange");
Execute Javascript document.querySelector("locator").setAttribute("value", "${Yeterday_Date}");
Some datepickers have an onchange attribute which is invoked after readonly attribute is removed, so its better to remove both the attributes.
来源:https://stackoverflow.com/questions/56558626/selecting-readonly-datepickers-by-using-robotframework-and-input-date-into-it