Not able to maximize Chrome Window in headless mode

前端 未结 6 804
谎友^
谎友^ 2020-12-03 14:26

I recently upgraded my chrome version to 60 and chromedriver to version 2.31. Post that I have started getting the following exception when I try to do a maximize of the bro

6条回答
  •  甜味超标
    2020-12-03 14:41

    I'm using chromedriver 2.30 & chrome browser v60 through protractor. I run the tests headless too albeit I don't do it via chromeoptions. Rather I run tests headless using xvfb-run on a unix distribution. I'm encountering this issue also albeit it fails randomly for me. See stack below

    [chrome #11]       [31mWebDriverError: unknown error: failed to change window state to maximized, current state is normal
    [chrome #11]         (Session info: chrome=60.0.3112.78)
    [chrome #11]         (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 3.10.0-514.26.2.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
    [chrome #11]       Command duration or timeout: 122 milliseconds
    [chrome #11]       Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
    [chrome #11]       System info: host: 's1wfadvcilvm08', ip: '172.16.184.183', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-514.26.2.el7.x86_64', java.version: '1.8.0_141'
    [chrome #11]       Driver info: org.openqa.selenium.chrome.ChromeDriver
    [chrome #11]       Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57), userDataDir=/tmp/.org.chromium.Chromium.BNsN1w}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=60.0.3112.78, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
    

    My code at the beginning of each test does the following

    browser.manage().window().maximize();
    

    changing to

    driver.driver.manage().window().maximize();
    driver.manage().window().maximize();
    

    doesn't work for me either unfortunately. Shouldn't browser.manage().window().maximize() be still working as I'm running headless using xvfb-run rather than doing headless via chrome options?

提交回复
热议问题