My front-end developers, changed the layout of the application which I'm testing, therefore some buttons are in slightly different places. I have about 50 automated tests that I will have to improve if the idea I came up with proves to be ineffective. Namely, is it possible to change the size of the pages opened by default via Headless Chrome Driver? Most of my tests are as follows: open the website > log in > click the button on the top bar of the application. The problem is that the buttons have been hidden under the hamburger button, and one of the ways to "see" them is to reduce the resolution of Google Chrome to 80%, so is it possible to program Chrome Driver and/or Geckodriver to open websites and web apps in 80% resolution by default?
Asked
Active
Viewed 631 times
1 Answers
1
There is a way to achieve the browser resolution changes before tests are actually started. Below codes are for java and you can add them to your driver options. You can find your desired resolutions and then you can change the values.
ChromeOption for 1920 x 1080 :
ChromeOptions options = new ChromeOptions();
options.addArguments("--window-size=1920,1080");
Firefox options for 1920 x 1080 :
FirefoxDriver firefoxOptions = new FirefoxDriver();
firefoxOptions.addArguments("-width=1920");
firefoxOptions.addArguments("-height=1080");
You can also change resolution after driver initialization with dimension, here is an example for 1920 x 1080 :
Dimension dimensions = new Dimension(1920,1080);
driver.manage().window().setSize(dimensions);
For Magnification feature of browser you can use below codes :
Magnification + :
driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL,Keys.ADD));
Magnification - :
driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL,Keys.SUBTRACT));

sayhan
- 1,168
- 1
- 16
- 22
-
Thank you for answer. I have second question - is that possible to change the window magnification? It is where you press CTRL + -/+ using browser – matsi Aug 10 '21 at 07:58
-
You can use following code to perform one + action : driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL,Keys.ADD)); – sayhan Aug 10 '21 at 08:33