Reputation: 49
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
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
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:
driver.manage().window().maximize();
_driver.Manage().Window.Maximize();
driver.maximize_window()
@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