Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 428
icfantv Avatar asked Aug 23 '19 15:08

icfantv


People also ask

How does testcafe determine which browsers installed on my Machine?

As you can see, TestCafe automatically determines browsers installed on your machine. TestCafe will automatically open the chosen browsers and start test execution within them. When the test task is accomplished, the browser windows will be closed by TestCafe.

How do I create a test in testcafe?

After you click a fixture's Rec button, a browser loads the tested page and opens the recorder to create a test. A TestCafe test consists of the steps. Each step may contain an action or (one or more) assertions.

What is the testcafe API?

The TestCafe API includes methods that open, close, and switch between browser windows. You can test websites with pop-up windows and OAuth login forms, debug complex multi-window applications, or run multiple instances of the same web app side-by-side.

How do I run a test in a different browser?

Call the testcafe command with the --list-browsers flag to view a list of all available browsers. To run tests in a different local browser, specify the path to the browser’s executable file.


1 Answers

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
like image 172
Dmitry Ostashev Avatar answered Sep 26 '22 14:09

Dmitry Ostashev