【问题标题】:Checking the disappearance an element with selenium-webdriver and jest使用 selenium-webdriver 和 jest 检查元素的消失
【发布时间】:2020-11-17 21:02:47
【问题描述】:

不知道如何检查该元素是否已从 DOM 中消失。

  it('closes the modal on the close button click', async () => {
    await driver.get('http://localhost:3000/')
    const btn = await getElementXpath(driver, "//button[@class='Navbar__button']")
    await btn.click()

    const closeBtn = await getElementXpath(driver, "//button[@class='Modal__close']")
    await closeBtn.click()
    const modal = await getElementXpath(driver, '//div[@class="Modal__content"]')

    // here I need to check if the element is present
  })

【问题讨论】:

    标签: selenium selenium-webdriver jestjs


    【解决方案1】:

    您可以在 Selenium 中使用 EC(预期条件),单击 here 以查看文档。

    expected_conditions 模块包含一组预定义条件,例如 visibility_of_element_locatedinvisibility_of_element_located,在这种情况下可能很有用。

    【讨论】:

    • Node中没有EC
    • 我在 stackoverflow 上找到了this。希望你会发现它有用。
    猜你喜欢
    • 2016-07-28
    • 2017-07-03
    • 2014-07-18
    • 2017-09-12
    • 2013-10-30
    • 2016-02-29
    • 1970-01-01
    • 2018-08-28
    • 1970-01-01
    相关资源
    最近更新 更多