Does TestCafe have a way of setting the default browser window size?
Asked Answered
J

1

6

Reading the CLI Docs, there doesn't appear to be a way to set the default browser window size. Is there a way to do this so that each test or each test fixture doesn't have to?

I should point out that adding a resizeWindow call in each test, or even once per test fixture is not a scalable solution across many fixtures so the "proper" solution should/would involve some sort of config so it only needs to be set once.

Jeanett answered 23/8, 2019 at 15:55 Comment(0)
S
7

TestCafe does not have such an option out of the box. However, you can put the t.resizeWindow action into the beforeEach test hook.  

Another way is to run a browser with the special command line argument.   For example, the command line for Chrome:

testcafe "chrome '--window-size=800,600'" test.js
Sileas answered 26/8, 2019 at 14:40 Comment(4)
Yea, the test/test fixture option doesn't scale which is why we were looking to do it via config. Your solution should work perfectly. Thanks so much!Jeanett
Do you happen to know how to do this for IE11? Thanks.Jeanett
IE11 doesn't seem to provide a similar command-line option (learn.microsoft.com/en-us/previous-versions/windows/…). So it looks like this approach cannot be used with the IE browser.Proudfoot
Thanks this worked for me, however, I had to remove the qoutes. Instead it worked this way: chrome --window-size=1600,1200Trilinear

© 2022 - 2024 — McMap. All rights reserved.