Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules
build
npm-debug.log
.env
.DS_Store
.DS_Store
test/logs
*.txt
68 changes: 54 additions & 14 deletions test/specs/visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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);
Expand All @@ -50,22 +58,54 @@ 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'));
const loginButton = await browser.$('#log-in');
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());
});
});