From 6a63aea76fbfbb8b21312cd39990224f579953b9 Mon Sep 17 00:00:00 2001 From: jerseysu Date: Sun, 9 Aug 2020 01:29:41 +0800 Subject: [PATCH 1/4] refactor(visual): adjust the config --- test/specs/visual.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test/specs/visual.js b/test/specs/visual.js index f1c6840..a7745dc 100644 --- a/test/specs/visual.js +++ b/test/specs/visual.js @@ -11,8 +11,7 @@ const {Configuration} = require('@applitools/eyes-selenium'); const buildNumber = process.env.TRAVIS_JOB_NUMBER || 'local'; -let browser; -let eyes; +let browser; let eyes; describe('wdio6', function() { before(async () => { @@ -26,12 +25,13 @@ describe('wdio6', function() { }, }; - const configuration = await new Configuration(); + const configuration = await new Configuration() + .setApiKey(process.env.APPLITOOLS_API_KEY) + .setAppName('Demo App') + .setTestName(`Smoke Test #${buildNumber}`); + const runner = await new ClassicRunner(); eyes = await new Eyes(runner); - await eyes.setApiKey(process.env.APPLITOOLS_API_KEY); - await configuration.setAppName('Demo App'); - await configuration.setTestName(`Smoke Test #${buildNumber}`); await eyes.setConfiguration(configuration); browser = await remote(chrome); @@ -55,8 +55,11 @@ describe('wdio6', function() { await browser.url('https://demo.applitools.com'); + // To see visual bugs after the first run, use the commented line below instead. + // await driver.url("https://demo.applitools.com/index_v2.html"); + // Visual checkpoint #1. - await eyes.check('Login Window', Target.window()); + await eyes.check('Login Window', Target.window().fully()); // Click the "Log in" button. // await driver.click(By.id('log-in')); @@ -64,7 +67,7 @@ describe('wdio6', function() { await loginButton.click(); // Visual checkpoint #2. - await eyes.check('App Window', Target.window()); + await eyes.check('App Window', Target.window().fully()); await eyes.closeAsync(); }); From e0ca3523b38f86bf163561948050545d7c79d277 Mon Sep 17 00:00:00 2001 From: jerseysu Date: Sun, 9 Aug 2020 02:11:23 +0800 Subject: [PATCH 2/4] fix: error and add new test --- test/specs/visual.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/test/specs/visual.js b/test/specs/visual.js index a7745dc..2b6255e 100644 --- a/test/specs/visual.js +++ b/test/specs/visual.js @@ -4,7 +4,11 @@ const chromedriver = require('chromedriver'); const {remote} = require('webdriverio'); const { ClassicRunner, + ConsoleLogHandler, + // DeviceName, Eyes, + FileLogHandler, + // ScreenOrientation, Target, } = require('@applitools/eyes-webdriverio'); const {Configuration} = require('@applitools/eyes-selenium'); @@ -26,13 +30,17 @@ describe('wdio6', function() { }; const configuration = await new Configuration() + // .addDeviceEmulation(DeviceName.iPhone_X, ScreenOrientation.PORTRAIT) .setApiKey(process.env.APPLITOOLS_API_KEY) .setAppName('Demo App') - .setTestName(`Smoke Test #${buildNumber}`); + .setTestName(`Smoke Test #${buildNumber}`) + .setViewportSize({width: 1024, height: 768}); const runner = await new ClassicRunner(); eyes = await new Eyes(runner); await eyes.setConfiguration(configuration); + await eyes.setLogHandler(new ConsoleLogHandler(true)); + await eyes.setLogHandler(new FileLogHandler(true, 'test/logs/eyes.log', false)); browser = await remote(chrome); }); @@ -50,13 +58,13 @@ describe('wdio6', function() { await chromedriver.stop(); }); - it('Classic Runner Test', async () => { + it('Test - Basic Check', async () => { await eyes.open(browser); await browser.url('https://demo.applitools.com'); // To see visual bugs after the first run, use the commented line below instead. - // await driver.url("https://demo.applitools.com/index_v2.html"); + // await driver.url('https://demo.applitools.com/index_v2.html'); // Visual checkpoint #1. await eyes.check('Login Window', Target.window().fully()); @@ -71,4 +79,14 @@ describe('wdio6', function() { await eyes.closeAsync(); }); + + it('Test - Baidu', async () => { + await eyes.open(browser); + await browser.url('https://www.baidu.com'); + + // Visual checkpoint #1. + await eyes.check('Baidu', Target.window().fully()); + + await eyes.closeAsync(); + }); }); From 9a001f05568d2c88bd2908c16e24ebfa1f41624d Mon Sep 17 00:00:00 2001 From: jerseysu Date: Sun, 9 Aug 2020 02:12:22 +0800 Subject: [PATCH 3/4] chore(gitignore): add more condition --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6f81168..bad0b61 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ node_modules build npm-debug.log .env -.DS_Store \ No newline at end of file +.DS_Store +test/logs +*.txt From 0883e06fdd951e72ad8c42794efe750b21099a7f Mon Sep 17 00:00:00 2001 From: jerseysu Date: Sun, 9 Aug 2020 12:16:12 +0800 Subject: [PATCH 4/4] feat: add new test --- test/specs/visual.js | 55 +++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/test/specs/visual.js b/test/specs/visual.js index 2b6255e..88fcede 100644 --- a/test/specs/visual.js +++ b/test/specs/visual.js @@ -15,38 +15,38 @@ const {Configuration} = require('@applitools/eyes-selenium'); const buildNumber = process.env.TRAVIS_JOB_NUMBER || 'local'; -let browser; let eyes; +let browser; let eyes; let configuration; describe('wdio6', function() { before(async () => { await chromedriver.start(); - }); - - beforeEach(async () => { - const chrome = { - capabilities: { - browserName: 'chrome', - }, - }; - - const configuration = await new Configuration() + configuration = await new Configuration() // .addDeviceEmulation(DeviceName.iPhone_X, ScreenOrientation.PORTRAIT) .setApiKey(process.env.APPLITOOLS_API_KEY) - .setAppName('Demo App') - .setTestName(`Smoke Test #${buildNumber}`) + .setAppName(`Demo App`) .setViewportSize({width: 1024, height: 768}); const runner = await new ClassicRunner(); + eyes = await new Eyes(runner); await eyes.setConfiguration(configuration); await eyes.setLogHandler(new ConsoleLogHandler(true)); await eyes.setLogHandler(new FileLogHandler(true, 'test/logs/eyes.log', false)); + }); + + beforeEach(async () => { + const chrome = { + capabilities: { + browserName: 'chrome', + }, + }; browser = await remote(chrome); }); afterEach(async () => { await browser.deleteSession(); + await eyes.close(false); await eyes.abortIfNotClosed(); const results = await eyes.getRunner().getAllTestResults(false); @@ -58,7 +58,9 @@ describe('wdio6', function() { await chromedriver.stop(); }); - it('Test - Basic Check', async () => { + it(`Test - Basic Check - #${buildNumber}`, async () => { + await configuration.setTestName(`Basic`); + await eyes.setConfiguration(configuration); await eyes.open(browser); await browser.url('https://demo.applitools.com'); @@ -77,16 +79,33 @@ describe('wdio6', function() { // Visual checkpoint #2. await eyes.check('App Window', Target.window().fully()); - await eyes.closeAsync(); + // await eyes.closeAsync(); }); - it('Test - Baidu', async () => { + it(`Test - Baidu - #${buildNumber}`, async () => { + await configuration.setTestName(`Baidu`); + await eyes.setConfiguration(configuration); await eyes.open(browser); await browser.url('https://www.baidu.com'); - // Visual checkpoint #1. + // Visual checkpoint #3. await eyes.check('Baidu', Target.window().fully()); - await eyes.closeAsync(); + const searchButton = await browser.$('a#hotsearch-refresh-btn'); + await searchButton.click(); + + // Visual checkpoint #4. + await eyes.check('Baidu2', Target.window().fully()); + // await eyes.closeAsync(); + }); + + it(`Test - Y!TW - #${buildNumber}`, async () => { + await configuration.setTestName(`Y!TW`); + await eyes.setConfiguration(configuration); + await eyes.open(browser); + await browser.url('https://tw.yahoo.com'); + + // Visual checkpoint #5. + await eyes.check('Y! TW', Target.window()); }); });