Lipson T A
Lipson T A

Reputation: 49

How to fix the issue with very small screen size with Selenium webdriver

We just ran into a problem in our test automation infrastructure. The problem is that Windows defaults to a very small screen size (I assume 800x600) while running from Jenkins. Then if the website under test doesn't support such a small resolution without overlapping UI elements, the browser will fail some tests for items that are no longer visible. How can we solve this?

Upvotes: 2

Views: 3457

Answers (3)

BernardV
BernardV

Reputation: 766

Within your driver setup you can change the browser window size using the following in C#

driver.Manage().Window.Size = new System.Drawing.Size(width: 1600, height: 1200);

Upvotes: 0

Adam
Adam

Reputation: 213

It would be best maximize your window as soon as you instantiate your web driver instance.

I don't know the setup of your code but please try adding the following line after you've created an instance of the web driver you wish to use:

Java

driver.manage().window().maximize();

C#

_driver.Manage().Window.Maximize();

Python

driver.maximize_window()

Ruby

@driver.manage.window.maximize

The above may not work in Chrome - if this is the case, please use:

ChromeOptions options = new ChromeOptions();
options.addArgument("--start-maximized");
driver = new ChromeDriver(options);

As per @Ardesco & @Fenio comments - you can also set a specific dimension using:

driver.manage().window().setSize(new Dimension(1920,1080));

Upvotes: 4

Zoidburg
Zoidburg

Reputation: 159

driver.manage().window().fullscreen()

Upvotes: 0

Related Questions