Docker-selenium: How can we make the viewport bigger? how to change the resolution

Created on 20 May 2016  Â·  9Comments  Â·  Source: SeleniumHQ/docker-selenium

Hi,

Selenium can't click on elements because they are outside of the viewport (or website behaves differently because of resolution)
How can we make the viewport bigger? how to change the resolution

Thanks,
Roy

Most helpful comment

We had the same issue particularly with responsive websites, we fixed it by forcing the browser size to 1366x768 using the driver.manage as above, we also set the desktop size environment variables to 1920x1080x24 when starting the container.

-e SCREEN_HEIGHT=1080
-e SCREEN_WIDTH=1920
-e SCREEN_DEPTH=24

All 9 comments

Is the window opening as large as it can? Can you look into adding a driver.manage().window().maximize() at the start of your test? If you are on chrome you will have to add the maximize() flag differently.

Im having a similar problem. I can't click on elements and I think its because the window is just too small. I am maximizing the window on start.

Oddly enough, if I run the debug image it works.

We had the same issue particularly with responsive websites, we fixed it by forcing the browser size to 1366x768 using the driver.manage as above, we also set the desktop size environment variables to 1920x1080x24 when starting the container.

-e SCREEN_HEIGHT=1080
-e SCREEN_WIDTH=1920
-e SCREEN_DEPTH=24

@stephenrenshaw can you please clarify how to achieve 2 steps ( one for setting container size , second one for forcing browser size ) you mentioned in above comment ?

Sorry for keep promoting Zalenium here but so you know with Zalenium you can set the screen desktop resolution per test via the capatilibies, e.g.

capabilities: {
    browserName: 'chrome',
    screenResolution: '1680x1050',
    recordVideo: 'false'
}

Now I use the docker-compose file from below:

seleniumhub:
  image: selenium/hub
  ports:
    - 4444:4444
  environment:
    - GRID_MAX_SESSION=50
firefoxnode:
  image: selenium/node-firefox
  environment:
    SCREEN_WIDTH: 2880
    SCREEN_HEIGHT: 1800
  ports:
    - 5900
  links:
    - seleniumhub:hub
chromenode:
  image: selenium/node-chrome
  environment:
    SCREEN_WIDTH: 2880
    SCREEN_HEIGHT: 1800
  ports:
    - 5900
  links:
    - seleniumhub:hub

@roydekleijn Thanks for info & do you also set chrome browser size inside script as well ?

something like getDriver().manage().window().setSize(new Dimension(X, Y));

For chrome you can use the options below: (since .maxmize() doesn't work)

For MAC or Linux:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--kiosk");
driver = new ChromeDriver(chromeOptions);

For Windows:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--start-maximized");
driver = new ChromeDriver(chromeOptions);

On Fri, Apr 28, 2017 at 3:34 PM, Vikram Ingleshwar <[email protected]

wrote:

@roydekleijn https://github.com/roydekleijn Thanks for info & do you
also set chrome browser size inside script as well ?

something like getDriver().manage().window().setSize(new Dimension(X, Y));

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/SeleniumHQ/docker-selenium/issues/220#issuecomment-297999060,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABPP1SVAEXKEVMNf4_rPIaDhTG0yI5CHks5r0erngaJpZM4IjfNR
.

--

[image: --]
Roy de Kleijn
[image: http://]about.me/roydekleijn
http://about.me/roydekleijn?promo=email_sig

Closing as this was answered by the community.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

westlakem picture westlakem  Â·  5Comments

pfluegs picture pfluegs  Â·  4Comments

NeilJ247 picture NeilJ247  Â·  6Comments

geekdave picture geekdave  Â·  4Comments

matthewsamari picture matthewsamari  Â·  4Comments