Selecting Readonly Datepickers by using RobotFramework and input date into it

左心房为你撑大大i 提交于 2019-12-13 03:47:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!