【问题标题】:How to get xpath for dynamic iframe?如何获取动态 iframe 的 xpath?
【发布时间】:2020-07-30 00:29:07
【问题描述】:

你好, 在下面的应用程序中,CVV 在 iframe 中(如随附的屏幕截图所示),并且 iframe xpath 本质上是动态的。我尝试使用下面的 xpath,但由于数字不断变化,它失败了。你能帮忙看看如何处理这个动态 iframe xpath 吗?

//iframe[@id='cardinal-stepUpIframe-1586884117320']

【问题讨论】:

  • #stepUpView > div > iframe
  • @Taplar 但 iframe 编号是动态的。
  • 我的第一条评论和我的第二条评论都以选择器开头,根本不使用数字。
  • @Taplar- 我尝试了下面的 xpath - //iframe[contains(@id,'cardinal-stepUpIframe')]。希望它适用于我的自动化

标签: javascript java xpath iframe web-applications


【解决方案1】:

您可以在 xpath 或 css 中使用 start with,如下所示。

Xpath

//iframe[starts-with(@id,'cardinal-stepUpIframe-')]

CSS:

iframe[id^='cardinal-stepUpIframe-']

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-19
    • 1970-01-01
    • 1970-01-01
    • 2019-03-20
    相关资源
    最近更新 更多