Closed abacaj closed 7 years ago
Would passing "--window-size" to the chromeOptions args field works for you? See: http://peter.sh/experiments/chromium-command-line-switches/
Seems to manifest when there is a different version of chrome vs chromedriver. Is that possible in these dockerfiles?
I tried locally on my machine, using latest stable chrome and chromedriver 2.9 worked correctly when trying to resize window. Maybe resizing relies on xvfb? not sure about the details on this container.
Do you mind sharing a minimal set of code that could reproduce the issue?
The code I wrote is in javascript (node)
var webdriver = require("selenium-webdriver");
function getRemoteBrowser() {
var activePlatform = {
"browserName": "chrome",
"deviceName": "chrome",
"platformName": "LINUX"
};
var browser = new webdriver.Builder()
.withCapabilities(activePlatform)
.usingServer('http://192.168.33.10:4444/wd/hub')
.build();
var driverWindow = driver.manage().window();
driverWindow.maximize() // here
return browser;
}
According to https://bugs.chromium.org/p/chromedriver/issues/detail?id=1625#c39, headless mode does not support using extension to set the windows size, which seems to be what driver.manage().window().maximize() performed.
I believe that you can just use "--window-size" to set the dimension instead.
Cool, thank you for finding that. I will use the arguments then.
"--window-size" not working either.
Interesting. I am not able to reproduce it:
docker run --init -it --rm --name chrome --shm-size=1024m --cap-add=SYS_ADMIN \
--entrypoint=/usr/bin/google-chrome-unstable \
yukinying/chrome-headless-browser \
--headless --disable-gpu --window-size=200,300 \
--dump-dom http://howbigismybrowser.com/
And the result contains the correct dimension:
<div id="counter">
<span class="num">200</span>
<span id="divider"></span>
<span class="num">300</span>
</div>
Trying to resize window handle to generate larger screenshots:
Getting exception from selenium client:
browser.Manage().Window.Size <- new Drawing.Size(1400, 900)
Additional information: unknown error: cannot get automation extension