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
11 changes: 11 additions & 0 deletions WDIO7/UFG/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Applitools Tutorial - WebdriverIO 7

Get started with Applitools visual testing with this example of using the ClassicRunner with the Applitools WebdriverIO 7 SDK and TypeScript.


## More Information

Learn more about Applitools [Eyes](https://info.applitools.com/ucY77) and the [Ultrafast Test Cloud](https://info.applitools.com/ucY78) at [applitools.com](https://info.applitools.com/ucY76).

More about the Eyes WebdriverIO SDK:
* https://www.npmjs.com/package/@applitools/eyes-webdriverio
34 changes: 34 additions & 0 deletions WDIO7/UFG/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "tutorial-webdriverio7-typescript-basic",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha --require ts-node/register ./test/example-ufg.ts -t 300000",
"test:service": "wdio ./wdio.conf.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/applitools/tutorial-webdriverio5-basic.git"
},
"author": "Applitools Team <team@applitools.com> (http://www.applitools.com/)",
"license": "ISC",
"bugs": {
"url": "https://github.com/applitools/tutorial-webdriverio5-basic/issues"
},
"homepage": "https://github.com/applitools/tutorial-webdriverio5-basic#readme",
"devDependencies": {
"@applitools/eyes-webdriverio": "^5.34.12",
"@applitools/eyes-webdriverio5-service": "1.13.6",
"@types/node": "^15.3.0",
"@wdio/local-runner": "^7.19.4",
"@wdio/mocha-framework": "^7.19.3",
"@wdio/spec-reporter": "^7.19.1",
"chromedriver": "^100.0.0",
"mocha": "^8.4.0",
"ts-node": "^9.1.1",
"typescript": "^4.6.3",
"wdio-chromedriver-service": "^7.3.2",
"webdriverio": "^7.6.0"
}
}
72 changes: 72 additions & 0 deletions WDIO7/UFG/test/example-classic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use strict';

import { ClassicRunner, Eyes } from '@applitools/eyes-webdriverio';
import { remote, RemoteOptions } from 'webdriverio';

let browser: WebdriverIO.Browser;
let eyes: Eyes;

describe('wdio7', function () {
beforeEach(async () => {
// Use chrome browser

browser = await remote({
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
headless: true,
},
},
logLevel: 'silent',
} as RemoteOptions);

// Initialize the Runner for your test.
const runner = new ClassicRunner();

// Initialize the eyes SDK with configuration
eyes = new Eyes(runner, {
batch: {
name: 'Demo Batch - WDIO 7 - Ultrafast TS',
},
});
});

it('Classic Runner Test', async () => {
// Start the test by setting AUT's name, test name and viewport size (width X height)
await eyes.open(browser, {
appName: 'Demo App - WDIO 7 - Ultrafast TS',
testName: 'Smoke Test - WDIO 7 - Ultrafast TS',
viewportSize: {
width: 800,
height: 600,
},
});

// Navigate the browser to the "ACME" demo app.
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({ name: 'Login Window', fully: true });

// Click the "Log in" button.
const loginButton = await browser.$('#log-in');
await loginButton.click();

// Visual checkpoint #2.
await eyes.check({ name: 'App Window', fully: true });

// End the test
await eyes.close(true);
});

afterEach(async () => {
// Close the browser
await browser.deleteSession();

// If the test was aborted before eyes.close was called, ends the test as aborted.
await eyes.abort();
});
});
82 changes: 82 additions & 0 deletions WDIO7/UFG/test/example-ufg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
'use strict';

import { ClassicRunner, Eyes, Configuration, BrowserType, BatchInfo } from '@applitools/eyes-webdriverio';
import { remote, RemoteOptions } from 'webdriverio';

let browser: WebdriverIO.Browser;
let eyes: Eyes;

describe('wdio7', function () {
beforeEach(async () => {
// Use chrome browser

browser = await remote({
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
headless: true,
},
},
logLevel: 'silent',
} as RemoteOptions);

// Initialize the Runner for your test.
const runner = new ClassicRunner();

// Initialize the eyes SDK with configuration
eyes = new Eyes(runner);

// Initialize the eyes configuration
const configuration = new Configuration();

// create a new batch info instance and set it to the configuration
configuration.setBatch(new BatchInfo('Demo Batch - WDIO 5 - Ultrafast'))

// Add browsers with different viewports
configuration.addBrowser(1200, 800, BrowserType.CHROME);
configuration.addBrowser(1200, 800, BrowserType.FIREFOX);
configuration.addBrowser(1200, 800, BrowserType.EDGE_CHROMIUM);
configuration.addBrowser(1200, 800, BrowserType.SAFARI);

eyes.setConfiguration(configuration);
});

it('Classic Runner Test', async () => {
// Start the test by setting AUT's name, test name and viewport size (width X height)
await eyes.open(browser, {
appName: 'Demo App - WDIO 7 - Ultrafast TS',
testName: 'Smoke Test - WDIO 7 - Ultrafast TS',
viewportSize: {
width: 800,
height: 600,
},
});

// Navigate the browser to the "ACME" demo app.
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({ name: 'Login Window', fully: true });

// Click the "Log in" button.
const loginButton = await browser.$('#log-in');
await loginButton.click();

// Visual checkpoint #2.
await eyes.check({ name: 'App Window', fully: true });

// End the test
await eyes.close(true);
});

afterEach(async () => {
// Close the browser
await browser.deleteSession();

// If the test was aborted before eyes.close was called, ends the test as aborted.
await eyes.abort();
});
});
18 changes: 18 additions & 0 deletions WDIO7/UFG/test/specs/example_service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe('My Login application', () => {
it('should login with valid credentials', async () => {
await browser.url(`https://the-internet.herokuapp.com/login`);

await $('#username').setValue('tomsmith');
await $('#password').setValue('SuperSecretPassword!');
await $('button[type="submit"]').click();

await browser.eyesCheck('Typescript test');

await expect($('#flash')).toBeExisting();
await expect($('#flash')).toHaveTextContaining(
'You logged into a secure area!');

await browser.eyesGetTestResults();
});
});

12 changes: 12 additions & 0 deletions WDIO7/UFG/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"sourceMap": false,
"target": "es2019",
"module": "commonjs",
"removeComments": true,
"noImplicitAny": true,
"strictPropertyInitialization": true,
"strictNullChecks": true,
"types": ["node", "webdriverio/async", "@wdio/mocha-framework", "@applitools/eyes-webdriverio/types/v7"]
}
}
Loading