2015-09-13 110 views
-1

我無法使用硒webdriver從日曆下拉菜單中選擇一個值。日曆下拉菜單包含幾個與日期一起選擇的選項,我可以選擇日期而不是其他值。無法使用webdriver從日曆下拉菜單中選擇一個元素

<div class="dropDownDateBox OCYEKPD-yc-a" id="gwt-debug-lineItemType-startDateBox"> 
    <input type="text" class="gwt-DateBox"> 
    <span> </span> 
    <input type="text" class="timepicker"> 
    <span class="gray">EDT</span> 
    <div tabindex="0" class="OCYEKPD-E-c OCYEKPD-E-l" role="button" style="display: none;" aria-hidden="true"> 
     <input type="text" tabindex="-1" role="presentation" style="opacity: 0; height: 1px; width: 1px; z-index: -1; overflow: hidden; position: absolute;">   
     <span class="OCYEKPD-E-a"></span> 
     <div class="OCYEKPD-E-j goog-inline-block">Immediately</div> 
    </div> 
</div> 

這是我試過的代碼:

driver.findElement(By.id("gwt-debug-lineItemType-startDateBox")).click(); 
driver.findElement(By.xpath("//div[@id='gwt-debug-lineItemType-startDateBox']/div/div")).click(); 
+0

請檢查圖像。鏈接不在那裏。另外,添加堆棧跟蹤和附加消息。 – Saifur

+0

對不起,我只能上傳圖片。 – Vinay

+0

org.openqa.selenium.ElementNotVisibleException:元素當前不可見,因此可能不會與 – Vinay

回答

0

我得到了我想要通過下面的代碼:

driver.findElement(By.xpath("//div[@id='gwt-debug-lineItemType-startDateBox']/input[1]")).click(); 
driver.findElement(By.xpath("//div[text()='Immediately']")).click(); 

謝謝大家對你的幫助!萬分感激。

相關問題