简体   繁体   中英

how to select date in jquery date time picker in selenium python

I want to select the date and time from jquery date time picker which is present inside the iframe. I have switched to frame and clicked on the field which opens the date time picker but i want to send value from my code like send keys,but I'm not able to send. I'm doing this in python.

Here is my html code:

<div class="add_folder">
<form method="POST" action="some action url " id="add-attendance"> 
    <table class="table_blue"  >
       <tr>       
           <td> <label for="start_time">Start Time</label></td>       
           <td><input type="text" value="" name="start_time" id="start_time"/></td>
       </tr>
       <tr>       
           <td> <label for="end_time">End Time</label></td>       
           <td> <input type="text" value="" name="end_time" id="end_time"/> </td>    
       </tr>
       <tr> 

I did this using xpath but it didn't worked for me. Here is my selenium code to send keys:

driver.find_element_by_xpath('[@id="unowacalendar"]/div/div/table/tbody/tr[2]/td[5]').send_keys("2019-12-03")

Try targeting the input elements. For example:

driver.find_element_by_id('start_time').send_keys('yourValue')

You may need a wait eg

WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.ID , 'start_time'))).send_keys('yourValue')

Additional imports:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM