Issue with resizing browser window using Selenium Webdriver on Windows Server 2012 EC2 instance

Our automation tests using Selenium WebDriver are executed remotely in TeamCity on a Windows Server 2012 EC2 instance.

While working with Chrome on this instance, I encountered an issue where I am unable to resize the browser. Interestingly, resizing works perfectly fine with Firefox, but Chrome remains stuck at 1024 X 768.

I have experimented with various methods to try and resolve this problem, but unfortunately, none of them have yielded positive results so far.

ChromeOptions options = new ChromeOptions();
                options.AddArgument("--start-maximized")

WebDriver.Current.Manage().Window.Size = new Size(width, height);

ChromeOptions options = new ChromeOptions();
                options.AddArgument("window-size=1920,1080");

All these approaches worked flawlessly when tested locally on a Windows 10 machine running Chrome version 49.0.2623.110 and Chrome Driver version 2.9. However, the issue seems to persist only on the remote server.

My query is whether there exists any other method to resize the Chrome browser that I haven't tried yet or if it could potentially be an inherent problem with the ChromeDriver itself?

Answer №1

Would you be willing to give this a shot?

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

Answer №2

Typically, the maximum size of our chrome window is (1040, 784). Adjusting window size may not be straightforward. Instead, you should take the following steps:

  1. We should boost the Virtual memory of the EC2 instance.
  2. Alternatively, open your chrome in headless mode and then customize your screen size in your chrome settings.

I faced the same issue. I opted for the second solution as increasing the instance will lead to higher costs.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In search of a CSS selector that can target elements based on specific text contained within them

Query: <div class="btn btn-second-in-pair-not-desired btn-tall">Clear search</div> <div class="btn btn-second-in-pair-not-desired btn-tall">Raw Search</div> <div class="btn btn-second-in-pair-not-desired btn-tall">Basic Searc ...

Automating testing for numbered lists with CSS list-style-type decimal

I need help with a JavaScript and CSS project. I have a situation where I have a numbered list like this: Coffee Tea Cola Here is the code structure I am using: <!DOCTYPE html> <html> <head> <style> ul.a {list-style-type ...

Identify the CSS Framework being used in conjunction with Selenium

I have developed a program that crawls through various web pages and conducts tests using Selenium. My current task is to identify which CSS Frameworks are utilized on these websites for statistical analysis. Currently, I am using the FireFox Webdriver to ...

What is the best way to choose the next adjacent element using a CSS selector with Python Selenium?

The structure of the DOM is as shown below: <ul> <li> <a href="#" role="button" class="js-pagination link" data-page="1">1</a> </li> <li> <a href="#" role="button" class="js-pagination link active" data ...

Choosing Only the Visible Element with CSS

Within my program, there exists a text element that appears in two distinct sections: section A and section B (in the form of a popup). My intention was to create one object using CSS that could be utilized in both areas. By doing so, I would be able to em ...

Failing to verify the presence of specific text within a dropdown menu using Selenium

Previously, I successfully implemented this code, however, the HTML/CSS for the dropdown has since changed and now I am unable to get it to function correctly. Below is the structure for the dropdown code, with specific text highlighted that I am trying t ...

Selenium RC: Utilizing the CSS :contains pseudo-class for Element Selection

I have a task to verify that the data in a table row matches my expectations for two different tables. Let's look at an example using HTML: <table> <tr> <th>Table 1</th> </tr> <tr> <t ...

Error message: Unable to find child element in Selenium WebDriver

I'm currently dealing with a registration page where I encountered an issue. During my testing phase, I attempted to register without inputting a first name. Upon clicking the register button, I expected to see a 'Required' notification la ...

Unable to find the XPATH element with Selenium in Python due to element not being located

Can anyone help me troubleshoot? My XPATH seems correct, but it's showing 'no element found' error. I also attempted using find_elements(By.XPATH, "/html/body/div[3]/div[3]/div[5]/div[1]/table[*]/tbody/tr[*]/td[1]/a") import time from selen ...

Is it possible to target a specific element within one of two classes that share the same name using CSS or XPath in Webdriver.IO?

Currently, I am using Webdriver.io and facing a challenge in selecting an element within the "text-fields-container" class. This particular element happens to be a password field, and both classes share the same name. Can someone guide me on how to go abou ...

The CSS selector functions as expected when used in a web browser, however, it

While conducting test automation using Selenium, I typically rely on css selectors to find elements. However, I recently came across a peculiar issue. I observed that in certain cases, the css selector works perfectly when tested in the browser console. Fo ...