我想从jquery日期时间选择器中选择日期和时间,它存在于iframe中。我已经切换到frame,并单击了打开日期时间选择器的字段,但是我希望从代码中发送值,比如发送键,但是我无法发送。我用蟒蛇做的。
以下是我的html代码:
<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> 我使用xpath完成了这个任务,但是它对我没有用。下面是我发送密钥的selenium代码:
driver.find_element_by_xpath('[@id="unowacalendar"]/div/div/table/tbody/tr[2]/td[5]').send_keys("2019-12-03")发布于 2019-03-07 09:07:57
尝试以输入元素为目标。例如:
driver.find_element_by_id('start_time').send_keys('yourValue')你可能需要等待。
WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.ID , 'start_time'))).send_keys('yourValue')额外进口:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EChttps://stackoverflow.com/questions/55037837
复制相似问题