Skip to content

Commit 29eee7a

Browse files
committed
added back button test
1 parent 3f4e969 commit 29eee7a

File tree

2 files changed

+34
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)