From 3c47e0e0406796e716e52518b19b05bc9588dc03 Mon Sep 17 00:00:00 2001 From: BryceLTaylor Date: Wed, 29 May 2019 14:21:27 -0400 Subject: [PATCH 1/3] Make Find by Xpath ensure element is visible in integration tests --- test/helpers/selenium-helper.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/helpers/selenium-helper.js b/test/helpers/selenium-helper.js index ddafe8704..7063fc555 100644 --- a/test/helpers/selenium-helper.js +++ b/test/helpers/selenium-helper.js @@ -85,7 +85,11 @@ class SeleniumHelper { } findByXpath (xpath, timeoutMessage = `findByXpath timed out for path: ${xpath}`) { - return this.driver.wait(until.elementLocated(By.xpath(xpath)), DEFAULT_TIMEOUT_MILLISECONDS, timeoutMessage); + return this.driver.wait(until.elementLocated(By.xpath(xpath)), DEFAULT_TIMEOUT_MILLISECONDS, timeoutMessage) + .then(el => ( + this.driver.wait(el.isDisplayed(), DEFAULT_TIMEOUT_MILLISECONDS, `${xpath} is not visible`) + .then(() => el) + )); } findByText (text, scope) { From fa974c68bd312e8c8b3b0c255ea3e8ee8de5dab8 Mon Sep 17 00:00:00 2001 From: BryceLTaylor Date: Wed, 29 May 2019 14:23:25 -0400 Subject: [PATCH 2/3] Remove WaitUntilGone function from integration tests These were causing the tests to fail and should be fixed by the update to FindByXpath function. --- test/helpers/selenium-helper.js | 7 +------ test/integration/examples.test.js | 4 +--- test/integration/menu-bar.test.js | 5 +---- test/integration/project-loading.test.js | 5 +---- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/test/helpers/selenium-helper.js b/test/helpers/selenium-helper.js index 7063fc555..f10f0800a 100644 --- a/test/helpers/selenium-helper.js +++ b/test/helpers/selenium-helper.js @@ -26,8 +26,7 @@ class SeleniumHelper { 'getSauceDriver', 'getLogs', 'loadUri', - 'rightClickText', - 'waitUntilGone' + 'rightClickText' ]); } @@ -129,10 +128,6 @@ class SeleniumHelper { return this.clickXpath(`//button//*[contains(text(), '${text}')]`); } - waitUntilGone (element, timeoutMessage = 'waitUntilGone timed out') { - return this.driver.wait(until.stalenessOf(element), DEFAULT_TIMEOUT_MILLISECONDS, timeoutMessage); - } - getLogs (whitelist) { if (!whitelist) { // Default whitelist diff --git a/test/integration/examples.test.js b/test/integration/examples.test.js index aa867b041..c7b9836a2 100644 --- a/test/integration/examples.test.js +++ b/test/integration/examples.test.js @@ -11,8 +11,7 @@ const { findByXpath, getDriver, getLogs, - loadUri, - waitUntilGone + loadUri } = new SeleniumHelper(); let driver; @@ -31,7 +30,6 @@ describe('player example', () => { test('Load a project by ID', async () => { const projectId = '96708228'; await loadUri(`${uri}#${projectId}`); - await waitUntilGone(findByText('Loading')); await clickXpath('//img[@title="Go"]'); await new Promise(resolve => setTimeout(resolve, 2000)); await clickXpath('//img[@title="Stop"]'); diff --git a/test/integration/menu-bar.test.js b/test/integration/menu-bar.test.js index 7c653a907..3f6457e52 100644 --- a/test/integration/menu-bar.test.js +++ b/test/integration/menu-bar.test.js @@ -9,8 +9,7 @@ const { getDriver, loadUri, rightClickText, - scope, - waitUntilGone + scope } = new SeleniumHelper(); const uri = path.resolve(__dirname, '../../build/index.html'); @@ -78,7 +77,6 @@ describe('Menu bar settings', () => { await clickText('File'); const input = await findByXpath('//input[@accept=".sb,.sb2,.sb3"]'); await input.sendKeys(path.resolve(__dirname, '../fixtures/project1.sb3')); - await waitUntilGone(findByText('Loading')); // No replace alert since no changes were made await findByText('project1-sprite'); }); @@ -95,7 +93,6 @@ describe('Menu bar settings', () => { await input.sendKeys(path.resolve(__dirname, '../fixtures/project1.sb3')); await driver.switchTo().alert() .accept(); - await waitUntilGone(findByText('Loading')); await findByText('project1-sprite'); }); }); diff --git a/test/integration/project-loading.test.js b/test/integration/project-loading.test.js index e0c5e5d1f..00a0b0ee8 100644 --- a/test/integration/project-loading.test.js +++ b/test/integration/project-loading.test.js @@ -9,8 +9,7 @@ const { getDriver, getLogs, loadUri, - scope, - waitUntilGone + scope } = new SeleniumHelper(); const uri = path.resolve(__dirname, '../../build/index.html'); @@ -39,7 +38,6 @@ describe('Loading scratch gui', () => { const projectId = '96708228'; await loadUri(`${uri}#${projectId}`); - await waitUntilGone(findByText('Loading')); await clickXpath('//img[@title="Go"]'); await new Promise(resolve => setTimeout(resolve, 2000)); await clickXpath('//img[@title="Stop"]'); @@ -60,7 +58,6 @@ describe('Loading scratch gui', () => { .setSize(1920, 1080); const projectId = '96708228'; await loadUri(`${uri}#${projectId}`); - await waitUntilGone(findByText('Loading')); await clickXpath('//img[@title="Full Screen Control"]'); await new Promise(resolve => setTimeout(resolve, 500)); await clickXpath('//img[@title="Go"]'); From b9cefd325bea060c060298d9519619dbc990ce24 Mon Sep 17 00:00:00 2001 From: BryceLTaylor Date: Wed, 29 May 2019 14:45:57 -0400 Subject: [PATCH 3/3] Remove unused reference to findByText in integration tests --- test/integration/examples.test.js | 1 - test/integration/project-loading.test.js | 1 - 2 files changed, 2 deletions(-) diff --git a/test/integration/examples.test.js b/test/integration/examples.test.js index c7b9836a2..4a50c32ce 100644 --- a/test/integration/examples.test.js +++ b/test/integration/examples.test.js @@ -4,7 +4,6 @@ import path from 'path'; import SeleniumHelper from '../helpers/selenium-helper'; const { - findByText, clickButton, clickText, clickXpath, diff --git a/test/integration/project-loading.test.js b/test/integration/project-loading.test.js index 00a0b0ee8..7d857c286 100644 --- a/test/integration/project-loading.test.js +++ b/test/integration/project-loading.test.js @@ -4,7 +4,6 @@ import SeleniumHelper from '../helpers/selenium-helper'; const { clickText, clickXpath, - findByText, findByXpath, getDriver, getLogs,