Automated testing process js calendar control

Element to it as an example:

  <input type="text" name="deadline" id="deadline" value="" class="form-control form-date" autocomplete="off">

  Note: dr browser objects

    Thinking 1: First remove a read-only attribute js, then directly enter the desired date

Js removed by way of a read-only attribute: 
    js = "document.getElementById ( 'DEADLINE') .removeAttribute ( 'Readonly') ;"
    dr.execute_script (js)
Js read-only attribute is removed with two ways: 
    js = "document.getElementById ( 'DEADLINE') .ReadOnly = to false ;"
    dr.execute_script (js)
Direct Input:
    dr.find_element_by_id ( "DEADLINE") Clear () # to empty. input box
    dr.find_element_by_id ( "deadline") send_keys ( "2020-02-25") # again directly enter the date input box.

idea 2: first remove a read-only attribute js, then with the calendar control value js date to be desired

with the value js desired date to control:
   js_value = "document.getElementById('deadline').value='2020-02-25'"
   dr.execute_script(js_value)

    
 

Guess you like

Origin www.cnblogs.com/zjr-queen/p/12363353.html