wdio-screenshot
wdio-screenshot copied to clipboard
Multi-Browser Support
Currently wdio-screenshot does not work for browser.select(Browser) (WebDriverIO multiremote)
browser.select(browser).saveViewportScreenshot('great-shot.jpg')
For example, above call errors with:
Invalid attempt to destructure non-iterable instance running TypeError: Invalid attempt to destructure non-iterable instance
same here,
try to add two browser caps (chrome/ff) in wdio.conf.js by this example but its not working.
ERROR: undefined
:´(
EDIT:
i tried this and it works for me.
wdio.conf.js
...
capabilities: [{
maxInstances: 5,
browserName: 'chrome'
}, {
maxInstances: 5,
browserName: 'firefox'
}, {
maxInstances: 5,
browserName: 'safari'
}],
...
myTest.js
...
var browserName = browser.desiredCapabilities.browserName;
describe('save a full document screenshot.', function() {
it('should save a screenshot of complete document', function () {
browser.saveDocumentScreenshot('./screenshot/'+browserName+'.png');
});
});
Okay spent some time trying to fork the repo to make it compatible to Mutliremote and while running the very first tests, noticed a simple solution worth sharing.
In your wdio.conf.js
capabilities: {
browserC: {
desiredCapabilities: {
browserName: 'chrome'
}
},
browserS: {
desiredCapabilities: {
browserName: 'safari'
}
}
}
add this to to config to associate wd-screenshot commands to each of the browser instances
before: function () {
require('wdio-screenshot').init(browser, {});
require('wdio-screenshot').init(browserC, {});
require('wdio-screenshot').init(browserS, {});
}
That's it!
Now you can just call browserC.saveDocumentScreenshot(