Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-Browser Support #42

Open
webmagit opened this issue Nov 3, 2016 · 2 comments
Open

Multi-Browser Support #42

webmagit opened this issue Nov 3, 2016 · 2 comments

Comments

@webmagit
Copy link

webmagit commented Nov 3, 2016

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

@Arthuron
Copy link

Arthuron commented Dec 19, 2016

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');
  });
});

@blindedByCode
Copy link

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() and it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants