【问题标题】:how to select date in jquery date time picker in selenium python如何在硒python中的jquery日期时间选择器中选择日期
【发布时间】:2019-03-07 07:00:37
【问题描述】:

我想从 iframe 中的 jquery 日期时间选择器中选择日期和时间。我已切换到框架并单击打开日期时间选择器的字段,但我想从我的代码中发送值,如发送键,但我无法发送。我在 python 中这样做。

这是我的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 执行此操作,但它对我不起作用。这是我发送密钥的硒代码:

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

【问题讨论】:

    标签: python python-3.x selenium selenium-webdriver web-scraping


    【解决方案1】:

    尝试定位输入元素。例如:

    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 EC
    

    【讨论】:

      猜你喜欢
      • 2012-09-11
      • 2011-08-17
      • 2020-02-21
      • 1970-01-01
      • 2019-04-12
      • 1970-01-01
      • 1970-01-01
      • 2021-07-28
      • 1970-01-01
      相关资源
      最近更新 更多