使用SeleniumWebDriver和jest检查元素的消失
无法确定如何检查它元素已从DOM中消失使用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()
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。希望你会觉得有用。