Reputation: 44
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")
Upvotes: 1
Views: 420
Reputation: 84455
Try targeting the input elements. For example:
driver.find_element_by_id('start_time').send_keys('yourValue')
You may need a wait e.g.
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
Upvotes: 1