【问题标题】:How can I find an element in Puppeteer or Playwright using part of the element title?如何使用元素标题的一部分在 Puppeteer 或 Playwright 中找到元素?
【发布时间】:2020-10-29 13:20:55
【问题描述】:

我需要测试这个元素何时出现在 DOM 上。我想为此使用“标题”。 NBA 部分始终保持不变,另一部分 '0c381941-0' 是动态的。

我试过了

await page.waitForSelector('.identifier.identifier-group[title=`NBA ${idVariable}`)

但是那些反引号在那里是不可接受的。

有什么线索吗?

    <dl class="identifier identifier-group" title="NBA 0c381941-0">
    <dl class="player-identifier-label identifier" title="NHI 0c381941-0">
    <dt><span>NBA</span></dt>
    <dd><span>0c381941-0</span></dd>
    </dl>
    </dl>

【问题讨论】:

    标签: puppeteer playwright


    【解决方案1】:

    await page.waitForSelector(`.patient-identifier-label.identifier[title=NBA ${playerId}`)

    【讨论】:

      猜你喜欢
      • 2019-08-08
      • 1970-01-01
      • 2021-01-25
      • 2020-06-26
      • 2019-02-25
      • 2021-06-16
      • 1970-01-01
      • 2017-10-23
      • 2019-07-01
      相关资源
      最近更新 更多