How to set default browser window size in Protractor/WebdriverJS

前端 未结 8 1986
广开言路
广开言路 2020-11-27 15:14

For some reason when I run my tests at work the browser is maximized, but when I run them at home it only opens a browser window of about 50% width. This causes some discrep

8条回答
  •  时光说笑
    2020-11-27 16:10

    I simply added the code below in my protractor.conf.js file and it did work fine.

    onPrepare: function() {
        var width = 1600;
        var height = 1200;
        browser.driver.manage().window().setSize(width, height);
    },
    

    What purpose does the setTimeout and executeScript serve in your answer? I struggle to find best practices in the protractor documentation...

    To my mind, using directly maximize() is a bad idea and should not be the preferred method, since it would not set the same size on every machine where the tests are executed and could break responsive behaviours.

提交回复
热议问题