Set screen size in docker image


I am experiencing an issue when running tests on docker.

I have set the headless execution settings in Katalon to a windows size of 1080x720 via the Project Settings → Desired Capabilities → Chrome(Headless).

However when I run these tests in docker the windows size is different. How Can I set the correct size in Docker please?

Warning: I don’t use docker at all or headless very often.

Try this code as a starter…

import org.openqa.selenium.Dimension
import org.openqa.selenium.Point
import org.openqa.selenium.WebDriver as WebDriver
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

WebDriver driver = DriverFactory.getWebDriver()
driver.manage().window().setPosition(new Point(x, y))
driver.manage().window().setSize(new Dimension(width, height))


But it seems to be a setting with the docker container and xvfb that is missing to set the screensize of the container. Do you know anyone that could help?

@duyluong @ThanhTo @bionel

1 Like

this topic may help:

it is not enough just to set the browser windows size via capabilities or through the driver methods, but the virtual display size has to be set too, using xfvb-run. without specified size i think it will default to 800 x 600

however, xfvb is needed when using normal browser. with the headless one, the browser size can be set though the driver. WebUI.SetViewPortSize should do the trick, it was a bug in 6.something but according to @Zarashima the issue was fixed.

1 Like

Thank you all for the replies.

I now have the answer.

You need to add the environment variables to docker run in order to set the screen size.

docker run -e DISPLAY_CONFIGURATION=1080x1920x24

FYI i was trying:
docker run -e “DISPLAY_CONFIGURATION=1080x1920x24” but the quotes caused it to fail.

1 Like


You both need to set Chrome viewport in Desired Capabilities settings and configure docker environment as well:




Thank you, that’s of great help :slight_smile:

1 Like

I fixed this by using these environment variables.

I am using the docker image for selenium/node-chrome-debug

1 Like