-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplitools.js
44 lines (33 loc) · 1.27 KB
/
applitools.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const browserOptions = require('./wdio.conf');
const applitoolsKey = process.env.APPLITOOLS_KEY;
async function main() {
const webdriverio = require('webdriverio');
// Open a Chrome browser.
const driver = webdriverio.remote(browserOptions);
let browser = driver.init();
// Initialize the eyes SDK and set your private API key.
const { Eyes, Target } = require('@applitools/eyes.webdriverio');
let eyes = new Eyes();
eyes.setApiKey(applitoolsKey);
eyes.setForceFullPageScreenshot(true);
try {
// Start the test and set the browser's viewport size to 800x600.
await eyes.open(browser, 'Hello World!', 'My first Javascript test Modified!', { width: 800, height: 600 });
// Navigate the browser to the "hello world!" web-site.
await browser.url('https://applitools.com/');
// Visual checkpoint #1.
await eyes.check('Main Page', Target.window());
// Click the "Click me!" button.
await browser.click('button');
// // Visual checkpoint #2.
// await eyes.check('Click!', Target.window());
// End the test.
await eyes.close();
} finally {
// Close the browser.
await browser.end();
// If the test was aborted before eyes.close was called ends the test as aborted.
await eyes.abortIfNotClosed();
}
}
main();