2015-09-13 64 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(); 

谢谢大家对你的帮助!万分感激。

相关问题