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 diff --git a/test/specs/visual.js b/test/specs/visual.js index f1c6840..88fcede 100644 --- a/test/specs/visual.js +++ b/test/specs/visual.js @@ -4,19 +4,34 @@ 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'); 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(); + configuration = await new Configuration() + // .addDeviceEmulation(DeviceName.iPhone_X, ScreenOrientation.PORTRAIT) + .setApiKey(process.env.APPLITOOLS_API_KEY) + .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 () => { @@ -26,19 +41,12 @@ describe('wdio6', function() { }, }; - const configuration = await new Configuration(); - 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); }); afterEach(async () => { await browser.deleteSession(); + await eyes.close(false); await eyes.abortIfNotClosed(); const results = await eyes.getRunner().getAllTestResults(false); @@ -50,13 +58,18 @@ describe('wdio6', function() { await chromedriver.stop(); }); - it('Classic Runner Test', 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'); + // 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,8 +77,35 @@ 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(); + }); + + 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 #3. + await eyes.check('Baidu', Target.window().fully()); + + 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'); - await eyes.closeAsync(); + // Visual checkpoint #5. + await eyes.check('Y! TW', Target.window()); }); });