【问题标题】:Unable to create xpath for dynamic elements in a web table?无法为 web 表中的动态元素创建 xpath?
【发布时间】:2017-10-29 09:02:18
【问题描述】:

例如获取下方图片中突出显示的元素

我尝试过//div[@class='x-grid-item-container']/table/tbody/tr[@class='x-grid-row']/td,但在td 之后我不确定该使用什么。

【问题讨论】:

  • 没有你的 html 代码我怎么知道?
  • 这段文字Waiting for CS Verification以前知道吗?还是您只想通过代码获得?
  • 它正在被填充到网络表中。
  • 我想通过代码得到它
  • @ChandaKorat我找到了你的问题。谢谢

标签: selenium xpath web selenium-webdriver element


【解决方案1】:

您可以使用以下 xpath :

Xpath = "[contains(text()='Waiting for CS Verification')]"

希望对你有所帮助。

【讨论】:

  • 这给了我当前页和最后一页上的所有元素,文本相同
【解决方案2】:

我假设(因为 html 不完整)使用 xpath //div[@class='x-grid-item-container']/table/tbody/tr[@class='x-grid-row']/td,您已经到达包含所需 font 元素的必填字段。在这种情况下,您可以使用以下 xpath

//div[@class='x-grid-item-container']/table/tbody/tr[@class='x-grid-row']/td/descendant::font[normalize-space(text())='Waiting for CS Verification']

让我知道,这个 xpath 是否适合你。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-01
    • 2014-02-12
    • 1970-01-01
    • 2015-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多