0

I need a browser in Selenium to work as if it's maximized, so that website that I process perceived it as maximized, but I want it really to be minimized, so that I could work in parallel while the script executes. The simple: driver.maximize_window() just maximizes windows.

So, is there a way for a window of browser to be maximized for website, but in reality minimized?

DmytroSytro
  • 579
  • 4
  • 15

4 Answers4

1

You can try just running it in a small window instead of Maximized or Minimized.

Don't tell the browser to do anything in terms of size.

So where you tell Selenium

browser.maximize_window()

Erase or comment it out, and run the script that way.

It's either that or use multiple screens.

Crow
  • 15
  • 3
1

If you want to work while WebDriver is executed, you can created a virtual instance (with e.g. VirtualBox or HyperV) an run test suite in VM.

JanZ
  • 584
  • 2
  • 13
1

Several approaches here, depending on what your needs are.

First, most browser allow setting screen size when they are fired up. See details here How do I set browser width and height in Selenium WebDriver? Chrome, for example, can be controlled from outside of the selenium script either with ini files where you set your screen size properties or via command line arguments. See this page for specific args for chromium for example: https://peter.sh/experiments/chromium-command-line-switches/

Secondly, you could start your browser in headless mode and restrict it a specific size. If you do so, your code will run in the headless browser, meaning you can't see it on a real screen. See the miriad of stackoverflow question addressing this, including this one: How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium?

Thirdly, you could start a virtual display of a certain size and have your driver maximize the browser in all the tests. Tools like xvfb are a god send here. How do I run Selenium in Xvfb?

Lastly, you could use a real display that's set in the resolution/dpi you need. See answers like this Resize display resolution using python with cross platform support

BoboDarph
  • 2,751
  • 1
  • 10
  • 15
0

Maximized is just a browser size from the site perspective. Set the browser size to the screen resolution of your desktop and minimize the browser.

JeffC
  • 22,180
  • 5
  • 32
  • 55