嘗試使用Selenium webdriver命令在Chrome --headless
上設置瀏覽器大小。如何在使用google-chrome -headless時設置瀏覽器窗口大小?
我得到這個webdriver的錯誤:
- Failed: unknown error: cannot get automation extension
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: headless chrome=58.0.3029.81)
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-72-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.07 seconds
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: '826f6a766112', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-72-generic', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5), userDataDir=/tmp/.org.chromium.Chromium.cuymDL}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=58.0.3029.81, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
Session ID: 9569e5ebd8f7540ce510b20647443baf
您能否提供以下信息:1.您使用HtmlUnitDriver或PhantomJSDriver的無頭瀏覽器? 2.你能分享你想要訪問的網址嗎? 3.你的步驟是什麼? 4.你觀察到什麼錯誤? – DebanjanB
沒有幻影,這是真正的Chrome瀏覽器,真正無頭。我找到了答案,見下文。 –