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.

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
icfantv
  • 4,523
  • 7
  • 36
  • 53

1 Answers1

6

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
Dmitry Ostashev
  • 2,305
  • 1
  • 5
  • 21
  • 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! – icfantv Aug 26 '19 at 15:11
  • Do you happen to know how to do this for IE11? Thanks. – icfantv Sep 18 '19 at 22:30
  • IE11 doesn't seem to provide a similar command-line option (https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/general-info/hh826025(v=vs.85)). So it looks like this approach cannot be used with the IE browser. – Alexey Lindberg Sep 19 '19 at 15:47
  • Thanks this worked for me, however, I had to remove the qoutes. Instead it worked this way: `chrome --window-size=1600,1200` – Rasmus Puls Jul 18 '22 at 13:43