Skip to content

Instantly share code, notes, and snippets.

@benjiwheeler
Created December 19, 2018 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjiwheeler/f5243f018c136ccb87e53a948778dcdd to your computer and use it in GitHub Desktop.
Save benjiwheeler/f5243f018c136ccb87e53a948778dcdd to your computer and use it in GitHub Desktop.
Selenium test code for browsing back and confirming that page is gone
elementIsVisible (element) {
return this.driver.wait(until.elementIsVisible(element));
}
elementIsNotVisible (element) {
return this.driver.wait(until.elementIsNotVisible(element));
}
const abbyElement = await findByText('Abby'); // Should show editor for new costume
await elementIsVisible(abbyElement);
await new Promise(resolve => setTimeout(resolve, 10000)); // Wait for scroll animation
await driver.navigate().back();
try {
await elementIsVisible(abbyElement); // should throw StaleElementReferenceError
throw 'ShouldNotGetHere'; // eslint-disable-line no-throw-literal
} catch (e) {
expect(e.constructor.name).toEqual('StaleElementReferenceError');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment