以下是我的HTML代码
<td class="MenuEntryName" nowrap="">Business Insurance</td>`
当鼠标悬停在它上面时,std代码变为
<td class="MenuEntryNameHover" nowrap="">Business Insurance</td>
我已经尝试过使用动作类
WebElement SelectBusinessInsurance1 = driver.findElement(By.xpath("//td[contains(@class, 'MenuEntryName') and text()='Business Insurance']"));
Actions action = new Actions(driver);
WebElement mainMenu = driver.findElement(By.xpath("//td[contains(@class, 'MenuEntryNameHover') and text()='Business Insurance']"));
action.moveToElement(mainMenu).moveToElement(SelectBusinessInsurance1).click().build().perform();
答案 0 :(得分:0)
也许下面的Xpath可以帮助你
//td[contains(@class, 'MenuEntryName') and contains(text(), 'Business Insurance')]
如果类是menuEntry或menuEntryName
,它应该得到td无关紧要