Service Options
Service options are the options that can be set when the service is instantiated and will be used for each method call.
// wdio.conf.(js|ts)
export const config = {
// ...
// =====
// Setup
// =====
services: [
[
"visual",
{
// The options
},
],
],
// ...
};
Default Options
addressBarShadowPadding
- Type:
number
- Mandatory: No
- Default:
6
- Supported: Web
The padding needs to be added to the address bar on iOS and Android to do a proper cutout of the viewport.
autoElementScroll
- Type:
boolean
- Mandatory: No
- Default:
true
- Supported: Web, Hybrid App (Webview)
This option allows you to disable the automatic scrolling of the element into the view when an element screenshot is created.
addIOSBezelCorners
- Type:
boolean
- Mandatory: No
- Default:
false
- Supported: Web, Hybrid App (Webview), Native App
Add bezel corners and notch/dynamic island to the screenshot for iOS devices.
This can only be done when the device name CAN automatically be determined and matches the following list of normalized device names. Normalizing will be done by this module. iPhone:
- iPhone X:
iphonex
- iPhone XS:
iphonexs
- iPhone XS Max:
iphonexsmax
- iPhone XR:
iphonexr
- iPhone 11:
iphone11
- iPhone 11 Pro:
iphone11pro
- iPhone 11 Pro Max:
iphone11promax
- iPhone 12:
iphone12
- iPhone 12 Mini:
iphone12mini
- iPhone 12 Pro:
iphone12pro
- iPhone 12 Pro Max:
iphone12promax
- iPhone 13:
iphone13
- iPhone 13 Mini:
iphone13mini
- iPhone 13 Pro:
iphone13pro
- iPhone 13 Pro Max:
iphone13promax
- iPhone 14:
iphone14
- iPhone 14 Plus:
iphone14plus
- iPhone 14 Pro:
iphone14pro
- iPhone 14 Pro Max:
iphone14promax
iPads: - iPad Mini 6th Generation:
ipadmini
- iPad Air 4th Generation:
ipadair
- iPad Air 5th Generation:
ipadair
- iPad Pro (11-inch) 1st Generation:
ipadpro11
- iPad Pro (11-inch) 2nd Generation:
ipadpro11
- iPad Pro (11-inch) 3rd Generation:
ipadpro11
- iPad Pro (12.9-inch) 3rd Generation:
ipadpro129
- iPad Pro (12.9-inch) 4th Generation:
ipadpro129
- iPad Pro (12.9-inch) 5th Generation:
ipadpro129
autoSaveBaseline
- Type:
boolean
- Mandatory: No
- Default:
true
- Supported: Web, Hybrid App (Webview), Native App
If no baseline image is found during the comparison the image is automatically copied to the baseline folder.
baselineFolder
- Type:
any
- Mandatory: No
- Default:
.path/to/testfile/__snapshots__/
- Supported: Web, Hybrid App (Webview), Native App
The directory will hold all the baseline images that are used during the comparison. If not set, the default value will be used which will store the files in a __snapshots__/
-folder next to the spec that executes the visual tests. A function that accepts an option object can also be used to set the baselineFolder
value:
{
baselineFolder: (options) => {
const testFolder = path.dirname(options.specs[0]);
return path.join(testFolder, "snapshots", type);
};
}
clearRuntimeFolder
- Type:
boolean
- Mandatory: No
- Default:
false
- Supported: Web, Hybrid App (Webview), Native App
Delete runtime folder (actual
& `diff) on initialization
This will only work when the screenshotPath
is set through the plugin options, and WILL NOT WORK when you set the folders in the methods
createJsonReportFiles
(NEW)
- Type:
boolean
- Mandatory: No
- Default:
false
You now have the option to export the compare results into a JSON report file. By providing the option createJsonReportFiles: true
, each image that is compared will create a report stored in the actual
folder, next to each actual
image result. The output will look like this:
{
"parent": "check methods",
"test": "should fail comparing with a baseline",
"tag": "examplePageFail",
"instanceData": {
"browser": {
"name": "chrome-headless-shell",
"version": "126.0.6478.183"
},
"platform": {
"name": "mac",
"version": "not-known"
}
},
"commandName": "checkScreen",
"boundingBoxes": {
"diffBoundingBoxes": [
{
"left": 1088,
"top": 717,
"right": 1186,
"bottom": 730
}
//....
],
"ignoredBoxes": [
{
"left": 159,
"top": 652,
"right": 356,
"bottom": 703
}
//...
]
},
"fileData": {
"actualFilePath": "/Users/wdio/visual-testing/.tmp/actual/desktop_chrome-headless-shellexamplePageFail-local-chrome-latest-1366x768.png",
"baselineFilePath": "/Users/wdio/visual-testing/localBaseline/desktop_chrome-headless-shellexamplePageFail-local-chrome-latest-1366x768.png",
"diffFilePath": "/Users/wdio/visual-testing/.tmp/diff/desktop_chrome-headless-shell/examplePageFail-local-chrome-latest-1366x768png",
"fileName": "examplePageFail-local-chrome-latest-1366x768.png",
"size": {
"actual": {
"height": 768,
"width": 1366
},
"baseline": {
"height": 768,
"width": 1366
},
"diff": {
"height": 768,
"width": 1366
}
}
},
"misMatchPercentage": "12.90",
"rawMisMatchPercentage": 12.900729014153246
}
When all tests are executed, a new JSON file with the collection of the comparisons will be generated and can be found in the root of your actual
folder. The data is grouped by:
describe
for Jasmine/Mocha orFeature
for CucumberJSit
for Jasmine/Mocha orScenario
for CucumberJS and then sorted by:commandName
, which are the compare method names used to compare the imagesinstanceData
, browser first, then device, then platform it will look like this
[
{
"description": "check methods",
"data": [
{
"test": "should fail comparing with a baseline",
"data": [
{
"tag": "examplePageFail",
"instanceData": {},
"commandName": "checkScreen",
"framework": "mocha",
"boundingBoxes": {
"diffBoundingBoxes": [],
"ignoredBoxes": []
},
"fileData": {},
"misMatchPercentage": "14.34",
"rawMisMatchPercentage": 14.335403703025868
},
{
"tag": "exampleElementFail",
"instanceData": {},
"commandName": "checkElement",
"framework": "mocha",
"boundingBoxes": {
"diffBoundingBoxes": [],
"ignoredBoxes": []
},
"fileData": {},
"misMatchPercentage": "1.34",
"rawMisMatchPercentage": 1.335403703025868
}
]
}
]
}
]