Skip to content

Commit 54a1a60

Browse files
committed
test: fix sprite library test WRT SeleniumHelper changes
1 parent 87b86b6 commit 54a1a60

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

test/integration/sprites.test.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import path from 'path';
22
import SeleniumHelper from '../helpers/selenium-helper';
3+
import {StaleElementReferenceError} from 'selenium-webdriver/lib/error';
4+
import until from 'selenium-webdriver/lib/until';
35

46
const {
57
clickText,
@@ -152,20 +154,16 @@ describe('Working with sprites', () => {
152154
});
153155

154156
test('Use browser back button to close library', async () => {
155-
await driver.get('https://www.google.com');
156157
await loadUri(uri);
157158
await clickText('Costumes');
158159
await clickXpath('//button[@aria-label="Choose a Sprite"]');
159160
const abbyElement = await findByText('Abby'); // Should show editor for new costume
160161
await elementIsVisible(abbyElement);
161162
await driver.navigate().back();
162-
try {
163-
// should throw error because library is no longer visible
164-
await elementIsVisible(abbyElement);
165-
throw 'ShouldNotGetHere'; // eslint-disable-line no-throw-literal
166-
} catch (e) {
167-
expect(e.constructor.name).toEqual('StaleElementReferenceError');
168-
}
163+
// should throw error because library is no longer present
164+
await expect(driver.wait(until.elementIsVisible(abbyElement)))
165+
.rejects
166+
.toBeInstanceOf(StaleElementReferenceError);
169167
const costumesElement = await findByText('Costumes'); // Should show editor for new costume
170168
await elementIsVisible(costumesElement);
171169
const logs = await getLogs();

0 commit comments

Comments
 (0)