【问题标题】:How to acces dynamic td values using selenium java如何使用 selenium java 访问动态 td 值
【发布时间】:2015-03-06 02:57:00
【问题描述】:

下面是我的html代码

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

当鼠标悬停在它上面时,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();

【问题讨论】:

  • 您想要完成什么以及问题中提供的代码有哪些错误?
  • 实际,没有错误,问题是我无法点击new td
  • 你能提供网址或一些例子吗?
  • 欢迎来到 Stack Overflow!我编辑了您的问题以正确显示代码。不过,这条线很长——也许你应该引入换行符。

标签: java html selenium xpath


【解决方案1】:

也许下面的 Xpath 可以帮助你

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

无论类是 menuEntry 还是 menuEntryName 都应该得到 td

【讨论】:

  • 我可以点击第一个 td 然后 td 类发生变化,我无法点击第二个
猜你喜欢
  • 2022-01-20
  • 2013-09-06
  • 2013-07-26
  • 1970-01-01
  • 2021-07-19
  • 1970-01-01
  • 2023-02-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多