繁体   English   中英

如何使用selenium java访问动态td值

[英]How to acces dynamic td values using selenium java

下面是我的HTML代码

<td class="MenuEntryName" nowrap="">Business Insurance</td>`

当mosue在它上面盘旋时,td代码变为

<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();

也许下面的Xpath可以帮助你

//td[contains(@class, 'MenuEntryName') and contains(text(), 'Business Insurance')]

如果类是menuEntry或menuEntryName,它应该得到td无关紧要

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM