Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用SeleniumWebDriver和jest检查元素的消失_Selenium_Selenium Webdriver_Jestjs - Fatal编程技术网

使用SeleniumWebDriver和jest检查元素的消失

使用SeleniumWebDriver和jest检查元素的消失,selenium,selenium-webdriver,jestjs,Selenium,Selenium Webdriver,Jestjs,无法确定如何检查它元素已从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()

无法确定如何检查它元素已从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中使用EC(预期条件),单击查看文档


expected_conditions(预期_条件)模块包含一组预定义条件,例如位于的_元素的可见性_和位于的_元素的不可见性_,这在这种情况下可能很有用。

在stackoverflow上找不到节点中的EC。希望你会觉得有用。