I am struggling with a simple test using Jest and Selenium. I am testing if an element is removed from DOM after clicking on it.

I have tried this:

```
 test('User removes button after clicking on it', async (done) => {
    await driver.navigate().to('myProjectUrl');
    await driver.wait(until.elementLocated(By.css('.wrapper')), 10000);
    await driver.findElement(By.id('buttonId')).click();
    const deleteButton = await driver.findElement(By.id('buttonId'));
    expect(deleteButton.isDisplayed()).not.toEqual(true);
    done();
});

```

This seems to work. Test passes but I am getting:

```
StaleElementReferenceError: stale element reference: element is not attached to the page document

```

I have also tried this approach:

```
test('User removes button after clicking on it', async (done) => {
    await driver.navigate().to('myProjectUrl');
    await driver.wait(until.elementLocated(By.css('.wrapper')), 10000);
    await driver.findElement(By.id('buttonId')).click();
    const buttonOrMessage = await driver.wait(until.elementLocated(By.id('buttonId)), 300, 'missing_button');
    expect(buttonOrMessage).toEqual('missing_button');
    done();
});

```

This approach is returning error, not message as expected.

Any suggestions about what am I missing?
Your help would be appreciated.