How to maximize browser while running Selenium tests

Problem:

When I run my Selenium test the browser is not run maximized.  My website employs adaptive design so the menu gets collapsed on smaller screens. The window is just small enough that my menu is being collapsed during playback and causing my test to fail.

Solution:

Add the following line to your test before you navigate to the URL under test.

driver.Manage().Window.Maximize();

Adding this line will cause the browser window to be maximized before the test is executed.

Add comment

Loading