Nathan
Nathan

Reputation: 979

Capture full-height screenshots from Browserstack with Nightwatch

I want to capture full-height screenshots from a Nightwatch test, using Browserstack - I can capture the visible screen, but not the entire document.

I've tried this:

browser.execute(function () {
    // get document dimensions
}, [], function (result) {
    // browser.resizeWindow(to value sent as result)
    browser.saveScreenshot('filename.png');
});

but while the resulting image has the correct width, the height is limited to (I think) the resolution of the browser opened in Browserstack.

Is it possible to achieve this?

Upvotes: 5

Views: 2929

Answers (2)

Ala Eddine JEBALI
Ala Eddine JEBALI

Reputation: 7871

I solved this by doing 2 things:

  1. Add a high resolution values to my nightwatch.json:

    "yourPlatformName": {
        "desiredCapabilities": {
            "resolution": "1200x3000"
            //...
        }
    }

  1. Activate (uncomment) browser.resizeWindow() in your code to resizes the current window before making a capture:

     browser.execute(function () {
            // get document dimensions
        }, [], function (result) {
            // browser.resizeWindow(to value sent as result)
           browser.resizeWindow(1200, 3000);
           browser.saveScreenshot('filename.png');
    });

For me the size 1200x3000 is enough to capture the entire document. Try to increase those values and tests to meet your needs.

Upvotes: 2

SeleCoder
SeleCoder

Reputation: 343

I believe this is a limitation of the browser itself. For example, when testing on Chrome 29+ via Selenium, you will only be able to capture the visible area of the webpage displayed.

Are you able to capture a full page screenshot when running the test on the same browser locally on your machine? If yes, then you need to check this with BrowserStack. If it works locally then it should work on BrowserStack.

Upvotes: 0

Related Questions