Javascript 如何使用SeleniumWebDrive java选择span标记中存在的下拉选项?

Javascript 如何使用SeleniumWebDrive java选择span标记中存在的下拉选项?,javascript,selenium,selenium-webdriver,Javascript,Selenium,Selenium Webdriver,下拉主菜单在DIV和IMG标签中都有ID,我可以使用其中任何一个单击下拉主菜单,但是,我无法单击下拉选项,请帮助 主下拉列表的源代码: <div id="drop_mainmenu" tabindex="0">Navigator <img id="mainmenu_downarrow" border="0" class="ArrowImg" alt="" title="" src="/jde/share/images/menu_l23_button_dropdown_dwn.

下拉主菜单在DIV和IMG标签中都有ID,我可以使用其中任何一个单击下拉主菜单,但是,我无法单击下拉选项,请帮助

主下拉列表的源代码:

<div id="drop_mainmenu" tabindex="0">Navigator

<img id="mainmenu_downarrow" border="0" class="ArrowImg" alt="" title="" src="/jde/share/images/menu_l23_button_dropdown_dwn.png" onmouseover="this.src='/jde/share/images/menu_l23_button_dropdown_ovr.png'" onmousedown="this.src='/jde/share/images/menu_l23_button_dropdown_dwn.png'" onmouseout="this.src='/jde/share/images/menu_l23_button_dropdown_dwn.png'" data-pin-nopin="true"><br>
</div>
<span id="fldnode140398" style="color: #000000;font-style: normal;" title="Task Type:Task View, Fastpath Code: TV:140">Christie's Dubai</span>
导航器

其中一个下拉选项的源代码:

<div id="drop_mainmenu" tabindex="0">Navigator

<img id="mainmenu_downarrow" border="0" class="ArrowImg" alt="" title="" src="/jde/share/images/menu_l23_button_dropdown_dwn.png" onmouseover="this.src='/jde/share/images/menu_l23_button_dropdown_ovr.png'" onmousedown="this.src='/jde/share/images/menu_l23_button_dropdown_dwn.png'" onmouseout="this.src='/jde/share/images/menu_l23_button_dropdown_dwn.png'" data-pin-nopin="true"><br>
</div>
<span id="fldnode140398" style="color: #000000;font-style: normal;" title="Task Type:Task View, Fastpath Code: TV:140">Christie's Dubai</span>
佳士得迪拜酒店

尝试放置一些
等待
并尝试:

driver.findElement(By.id("mainmenu_downarrow")).click();
Thread.sleep(3000L);
driver.findElement(By.xpath(".//span[contains(text(), 'Christie's Dubai')]")).click();


为什么
无法单击它?共享您的代码这是我的代码,driver.findElement(By.id(“mainmenu_downarrow”))。单击();Select main menu_downarrow=new Select(driver.findElement(By.id)(“main menu downarrow”));主菜单_向下箭头。选择ByVisibleText(“佳士得迪拜”);我猜Select不起作用,因为现在有一个Select是在html代码下编写的。@Jagadeesh你试过我编辑的答案了吗?你的xpath在这里不起作用。。selenium无法识别
,以下是我用您的代码尝试的,但它不起作用。driver.findElement(By.id(“主菜单\下箭头”))。单击();线程。睡眠(3000L);findElement(By.xpath(“.//span[contains(text(),'Christie's Dubai']))。单击();