Skip to content

Commit d9ef29e

Browse files
committed
Updating WDIO demo
1 parent 2aa8e7e commit d9ef29e

File tree

3 files changed

+48
-61
lines changed

3 files changed

+48
-61
lines changed

README.md

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,36 @@
11
# Applitools Example: WebdriverIO in JavaScript
22

3-
This is the example project for the [WebdriverIO JavaScript tutorial](https://applitools.com/tutorials/quickstart/web/webdriverio).
4-
It shows how to start automating visual tests with the [Applitools Eyes](https://applitools.com/platform/eyes/)
5-
and [WebdriverIO](https://webdriver.io/) in JavaScript.
3+
Get started with Applitools Eyes visual testing with this example of using [WDIO](https://webdriver.io/) and our [WDIO SDK](https://applitools.com/tutorials/web/webdriverio).
64

7-
It uses:
5+
Learn more about how to install and start this project with our [WDIO tutorial](https://applitools.com/tutorials/quickstart/web/webdriverio)!
86

9-
* [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) as the programming language
10-
* [WebdriverIO](https://webdriver.io/) for browser automation
11-
* [Google Chrome](https://www.google.com/chrome/downloads/) as the local browser for testing
12-
* [npm](https://www.npmjs.com/) for dependency management
13-
* [Applitools Eyes](https://applitools.com/platform/eyes/) for visual testing
7+
# Installation & Run
8+
1. Install the dependencies
9+
```sh
10+
npm install
11+
npm install chromedriver --detect_chromedriver_version
12+
```
1413

15-
It can also run tests with:
14+
To authenticate via the Applitools server and run tests, you need to set your API key provided from Applitools Eyes. For details on how to retrieve your API key, see [the Applitools documentation](https://applitools.com/tutorials/getting-started/retrieve-api-key).
1615

17-
* [Applitools Ultrafast Grid](https://applitools.com/platform/ultrafast-grid/) for cross-browser execution
18-
* [Applitools Execution Cloud](https://applitools.com/platform/execution-cloud/) for self-healing remote WebDriver sessions
16+
2. Choose one of the following options to set your API Key.
17+
* Set your Applitools API Key as an environment variable.
18+
* macOS/Linux: `export APPLITOOLS_API_KEY=<Your API Key>`
19+
* Windows: `set APPLITOOLS_API_KEY=<Your API Key>`
20+
21+
* Set your Applitools API Key inside the **applitools.config.js** file via the `apiKey` setting.
22+
* Note: If you are not using the Eyes public cloud, you will need to update the `serverUrl` to your Eyes server URL in the **applitools.config.js** configuration file or set via an `APPLITOOLS_SERVER_URL` environment variable. See our [documentation](https://applitools.com/tutorials/sdks/webdriverio/advanced) for more information on these settings.
1923

20-
To run this example project, you'll need:
24+
3. Run the example test
25+
```sh
26+
npm tset
27+
```
2128

22-
1. A free [Applitools account](https://auth.applitools.com/users/register).
23-
2. The [Node.js](https://nodejs.org/en/) version 12 or higher.
24-
3. A good JavaScript editor, such as [Visual Studio Code](https://code.visualstudio.com/).
25-
4. [npm](https://www.npmjs.com/) (typically bundled with Node.js).
26-
5. An up-to-date version of [Google Chrome](https://www.google.com/chrome/downloads/).
27-
6. A corresponding version of [ChromeDriver](https://chromedriver.chromium.org/downloads).
29+
4. After the example tests complete. Visit your Applitools Eyes dashboard to view the results.
2830

29-
To install project dependencies, run:
31+
## More Information
3032

31-
```
32-
npm install
33-
npm install chromedriver --detect_chromedriver_version
34-
```
33+
Learn more about [Applitools Eyes](https://www.applitools.com) and the [Applitool Ultrafast Grid](https://applitools.com/platform/ultrafast-grid).
3534

36-
The main test case is [`acme-bank.test.js`](test/acme-bank.test.js).
37-
By default, the project will run tests with Ultrafast Grid but not Execution Cloud.
38-
You can change these settings in the test file.
39-
40-
To execute tests, set the `APPLITOOLS_API_KEY` environment variable
41-
to your [account's API key](https://applitools.com/tutorials/getting-started/setting-up-your-environment.html),
42-
and then run:
43-
44-
```
45-
npm test
46-
```
47-
48-
**For full instructions on running this project, take our
49-
[WebdriverIO JavaScript tutorial](https://applitools.com/tutorials/quickstart/web/webdriverio)!**
35+
More about the Eyes Storybook SDK:
36+
* https://www.npmjs.com/package/@applitools/eyes-storybook

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"author": "Applitools Team <[email protected]> (http://www.applitools.com/)",
1111
"license": "ISC",
1212
"dependencies": {
13-
"@applitools/eyes-webdriverio": "^5.44.0",
13+
"@applitools/eyes-webdriverio": "^5.58.2",
1414
"@wdio/cli": "^8.10.2",
1515
"@wdio/dot-reporter": "^8.10.2",
1616
"@wdio/local-runner": "^8.10.2",

test/acme-bank.test.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
const { remote } = require('webdriverio');
44

5-
const { Eyes,
5+
const { Eyes,
66
ClassicRunner,
7-
VisualGridRunner,
7+
VisualGridRunner,
88
RunnerOptions,
9-
Target,
10-
RectangleSize,
11-
Configuration,
9+
Target,
10+
RectangleSize,
11+
Configuration,
1212
BatchInfo,
1313
BrowserType,
1414
ScreenOrientation,
@@ -24,7 +24,7 @@ describe('ACME Bank', function () {
2424
// They are hard-coded here to keep the example project simple.
2525
const USE_ULTRAFAST_GRID = true;
2626
const USE_EXECUTION_CLOUD = false;
27-
27+
2828
// Test control inputs to read once and share for all tests
2929
var applitoolsApiKey;
3030

@@ -66,7 +66,7 @@ describe('ACME Bank', function () {
6666

6767
// Create a configuration for Applitools Eyes.
6868
config = new Configuration();
69-
69+
7070
// Set the Applitools API key so test results are uploaded to your account.
7171
// If you don't explicitly set the API key with this call,
7272
// then the SDK will automatically read the `APPLITOOLS_API_KEY` environment variable to fetch it.
@@ -89,13 +89,13 @@ describe('ACME Bank', function () {
8989
config.addDeviceEmulation(DeviceName.Nexus_10, ScreenOrientation.LANDSCAPE);
9090
}
9191
});
92-
93-
92+
93+
9494
beforeEach(async function () {
9595
// This method sets up each test with its own ChromeDriver and Applitools Eyes objects.
9696
// Even though this test will run visual checkpoints on different browsers in the Ultrafast Grid,
9797
// it still needs to run the test one time locally to capture snapshots.
98-
98+
9999
// Create the Applitools Eyes object connected to the runner and set its configuration.
100100
eyes = new Eyes(runner);
101101
eyes.setConfiguration(config);
@@ -118,27 +118,27 @@ describe('ACME Bank', function () {
118118
// Open Eyes to start visual testing.
119119
// It is a recommended practice to set all four inputs:
120120
browser = await eyes.open(
121-
121+
122122
// WebDriver object to "watch".
123123
browser,
124-
124+
125125
// The name of the application under test.
126126
// All tests for the same app should share the same app name.
127127
// Set this name wisely: Applitools features rely on a shared app name across tests.
128128
'ACME Bank',
129-
129+
130130
// The name of the test case for the given application.
131131
// Additional unique characteristics of the test may also be specified as part of the test name,
132132
// such as localization information ("Home Page - EN") or different user permissions ("Login by admin").
133133
this.currentTest.fullTitle(),
134-
134+
135135
// The viewport size for the local browser.
136136
// Eyes will resize the web browser to match the requested viewport size.
137137
// This parameter is optional but encouraged in order to produce consistent results.
138138
new RectangleSize(1200, 600)
139139
);
140140
});
141-
141+
142142
it('should log into a bank account', async () => {
143143
// This test covers login for the Applitools demo site, which is a dummy banking app.
144144
// The interactions use typical Selenium calls,
@@ -147,21 +147,21 @@ describe('ACME Bank', function () {
147147
// Traditional assertions that scrape the page for text values are not needed here.
148148

149149
// Load the login page.
150-
await browser.url('https://demo.applitools.com');
150+
await browser.url('https://sandbox.applitools.com/bank');
151151

152152
// Verify the full login page loaded correctly.
153153
await eyes.check(Target.window().fully().withName("Login page"));
154-
154+
155155
// Perform login.
156-
await browser.$("#username").setValue("andy");
157-
await browser.$("#password").setValue("i<3pandas");
156+
await browser.$("#username").setValue("Chris");
157+
await browser.$("#password").setValue("CorrectHorseBatteryStaple");
158158
await browser.$("#log-in").click();
159159

160160
// Verify the full main page loaded correctly.
161161
// This snapshot uses LAYOUT match level to avoid differences in closing time text.
162162
await eyes.check(Target.window().fully().withName("Main page").layout());
163163
});
164-
164+
165165
afterEach(async () => {
166166

167167
// Close Eyes to tell the server it should display the results.
@@ -177,12 +177,12 @@ describe('ACME Bank', function () {
177177
// If you want the ACME demo app test to wait synchronously for all checkpoints to complete, then use `eyes.close()`.
178178
// If any checkpoints are unresolved or failed, then `eyes.close()` will make the ACME demo app test fail.
179179
});
180-
180+
181181
after(async () => {
182182
// Close the batch and report visual differences to the console.
183183
// Note that it forces Mocha to wait synchronously for all visual checkpoints to complete.
184184
const allTestResults = await runner.getAllTestResults();
185185
console.log(allTestResults);
186186
});
187-
187+
188188
});

0 commit comments

Comments
 (0)