binarygiant
binarygiant

Reputation: 6422

Protractor Determine Screen Size/Resolution

Is there a way to determine the available screen size/resolution using Protractor?

I want to determine how big to make several browsers, and where to place them.

I know you can get/set window size using:

browser.driver.manage().window().setSize(1280, 1024);
browser.driver.manage().window().getSize();

But I can't find anything in the docs about available screen size/resolution.

Upvotes: 0

Views: 2005

Answers (1)

binarygiant
binarygiant

Reputation: 6422

I ended up using browser.executeScript to access the screen object.

browser.executeScript('return {' +
            'height: screen.availHeight,' +
            'width: screen.availWidth,' +
            'top: screen.availTop,' +
            'left: screen.availLeft};'
            )
            .then(function (result) {
                //make calculations
                browser.driver.manage().window.setSize(h,w);
                browser.driver.manage().window.setPosition(x,y);
            });

Upvotes: 3

Related Questions