Skip to content
Snippets Groups Projects
Commit 67074edb authored by Ben Wheeler's avatar Ben Wheeler
Browse files

added back button test

parent 3f4e9698
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,8 @@ class SeleniumHelper { ...@@ -14,6 +14,8 @@ class SeleniumHelper {
'clickText', 'clickText',
'clickButton', 'clickButton',
'clickXpath', 'clickXpath',
'elementIsVisible',
'elementIsNotVisible',
'findByText', 'findByText',
'findByXpath', 'findByXpath',
'getDriver', 'getDriver',
...@@ -24,6 +26,13 @@ class SeleniumHelper { ...@@ -24,6 +26,13 @@ class SeleniumHelper {
]); ]);
} }
elementIsVisible (element) {
return this.driver.wait(until.elementIsVisible(element));
}
elementIsNotVisible (element) {
return this.driver.wait(until.elementIsNotVisible(element));
}
get scope () { get scope () {
// List of useful xpath scopes for finding elements // List of useful xpath scopes for finding elements
return { return {
......
...@@ -4,6 +4,7 @@ import SeleniumHelper from '../helpers/selenium-helper'; ...@@ -4,6 +4,7 @@ import SeleniumHelper from '../helpers/selenium-helper';
const { const {
clickText, clickText,
clickXpath, clickXpath,
elementIsVisible,
findByText, findByText,
findByXpath, findByXpath,
getDriver, getDriver,
...@@ -124,4 +125,27 @@ describe('Working with sprites', () => { ...@@ -124,4 +125,27 @@ describe('Working with sprites', () => {
const logs = await getLogs(); const logs = await getLogs();
await expect(logs).toEqual([]); await expect(logs).toEqual([]);
}); });
test('Use browser back button to close library', async () => {
await driver.get('https://www.google.com');
await loadUri(uri);
await clickXpath('//button[@title="Try It"]');
await clickText('Costumes');
await clickXpath('//button[@aria-label="Choose a Sprite"]');
const abbyElement = await findByText('Abby'); // Should show editor for new costume
await elementIsVisible(abbyElement);
await driver.navigate().back();
try {
// should throw error because library is no longer visible
await elementIsVisible(abbyElement);
throw 'ShouldNotGetHere'; // eslint-disable-line no-throw-literal
} catch (e) {
expect(e.constructor.name).toEqual('StaleElementReferenceError');
}
const costumesElement = await findByText('Costumes'); // Should show editor for new costume
await elementIsVisible(costumesElement);
const logs = await getLogs();
await expect(logs).toEqual([]);
});
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment