Selenium webdriver 将鼠标悬停在菜单上,然后使用selenium vba单击子菜单项
我有一个这样的下拉菜单。使用selenium,我需要移动菜单,但可以通过ID、xPath等检索元素。 你能帮忙吗Selenium webdriver 将鼠标悬停在菜单上,然后使用selenium vba单击子菜单项,selenium-webdriver,mousehover,findelement,Selenium Webdriver,Mousehover,Findelement,我有一个这样的下拉菜单。使用selenium,我需要移动菜单,但可以通过ID、xPath等检索元素。 你能帮忙吗 <td id="140#200" nowrap="" class="k140" onclick="menuclic("140",this,"#200")" onmousedown="menudown("140",this)" onmouseup="menuup(&
<td id="140#200" nowrap="" class="k140" onclick="menuclic("140",this,"#200")" onmousedown="menudown("140",this)" onmouseup="menuup("140",this)" onmousemove="menumousemove("140",this,'#200')" onmouseover="menuover("140",this)" onmouseout="menuout("140",this)"> Suivi des réclamations </td>
Suivi des réclamations
你可以这样处理这个问题。当然,这只是一个例子
//Instantiate Action Class
Actions actions = new Actions(driver);
//Retrieve WebElement 'Music' to perform mouse hover
WebElement menuOption = driver.findElement(By.xpath(".//div[contains(text(),'Music')]"));
//Mouse hover menuOption 'Music'
actions.moveToElement(menuOption).perform();
System.out.println("Done Mouse hover on 'Music' from Menu");
//Now Select 'Rock' from sub menu which has got displayed on mouse hover of 'Music'
WebElement subMenuOption = driver.findElement(By.xpath(".//div[contains(text(),'Rock')]"));
//Mouse hover menuOption 'Rock'
actions.moveToElement(subMenuOption).perform();
System.out.println("Done Mouse hover on 'Rock' from Menu");
生成的图像是:
.该类在页面上似乎是动态的,只有静态但不唯一的ID。有什么建议吗?