Skip to content

Commit 67074ed

Browse files
committed
added back button test
1 parent 3f4e969 commit 67074ed

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

test/helpers/selenium-helper.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class SeleniumHelper {
1414
'clickText',
1515
'clickButton',
1616
'clickXpath',
17+
'elementIsVisible',
18+
'elementIsNotVisible',
1719
'findByText',
1820
'findByXpath',
1921
'getDriver',
@@ -24,6 +26,13 @@ class SeleniumHelper {
2426
]);
2527
}
2628

29+
elementIsVisible (element) {
30+
return this.driver.wait(until.elementIsVisible(element));
31+
}
32+
elementIsNotVisible (element) {
33+
return this.driver.wait(until.elementIsNotVisible(element));
34+
}
35+
2736
get scope () {
2837
// List of useful xpath scopes for finding elements
2938
return {

test/integration/sprites.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import SeleniumHelper from '../helpers/selenium-helper';
44
const {
55
clickText,
66
clickXpath,
7+
elementIsVisible,
78
findByText,
89
findByXpath,
910
getDriver,
@@ -124,4 +125,27 @@ describe('Working with sprites', () => {
124125
const logs = await getLogs();
125126
await expect(logs).toEqual([]);
126127
});
128+
129+
test('Use browser back button to close library', async () => {
130+
await driver.get('https://www.google.com');
131+
await loadUri(uri);
132+
await clickXpath('//button[@title="Try It"]');
133+
await clickText('Costumes');
134+
await clickXpath('//button[@aria-label="Choose a Sprite"]');
135+
const abbyElement = await findByText('Abby'); // Should show editor for new costume
136+
await elementIsVisible(abbyElement);
137+
await driver.navigate().back();
138+
try {
139+
// should throw error because library is no longer visible
140+
await elementIsVisible(abbyElement);
141+
throw 'ShouldNotGetHere'; // eslint-disable-line no-throw-literal
142+
} catch (e) {
143+
expect(e.constructor.name).toEqual('StaleElementReferenceError');
144+
}
145+
const costumesElement = await findByText('Costumes'); // Should show editor for new costume
146+
await elementIsVisible(costumesElement);
147+
const logs = await getLogs();
148+
await expect(logs).toEqual([]);
149+
});
150+
127151
});

0 commit comments

Comments
 (0)