Chrome canary headless mode does not work on windows10

感情迁移 提交于 2021-02-19 04:14:53

问题


Google Chrome Canary does not work with headless on Windows.

Chrome headless does not work on windows. The Error happens like following when I tried to execute below code. But it works on non-headless mode.

I know Canary is unstable but I want to using it to learning about web advanced spec.

This error caused by bug in canary? Or caused by my code?

code:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

op = Options()
op.binary_location = "C:\\Users\\username\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe"
op.add_argument("--headless")
op.add_argument("--disable-gpu")

driver = webdriver.Chrome("chromedriver.exe", chrome_options=op)

driver.get("http://www.google.com")

Error:

[1205/232511.644:ERROR:gpu_process_transport_factory.cc(1017)] Lost UI shared context.
[1205/232511.644:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.644:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics

DevTools listening on ws://127.0.0.1:12022/devtools/browser/3d7c8ff8-625a-4326-b968-bbff
[1205/232511.714:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.714:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[1205/232511.714:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.714:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[1205/232513.037:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232513.037:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics

OS: windows 10 Home 1709
Chrome: 65.0.3285.0 (Official Build) canary 64bit
ChromeDriver: 2.33.506120


回答1:


As your error logs reports as follows :

[1205/232511.644:ERROR:gpu_process_transport_factory.cc(1017)] Lost UI shared context.
[1205/232511.644:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.644:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics

I will suggest the following steps :

  • Uninstall Google Chrome Canary from your system through Revo Uninstaller
  • Use CCleaner tool to wipe off all the OS chores.
  • Install fresh Google Chrome Canary
  • Use the following code block :

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    op = Options()
    op.binary_location = "C:\\Users\\username\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe"
    op.add_argument("--headless")
    op.add_argument("--disable-gpu")
    driver = webdriver.Chrome(chrome_options=op, executable_path=r'C:\path\to\chromedriver.exe')
    driver.get("http://google.com/")
    

You can find about multiple ways to work with multiple Chrome Browser Binaries in Set chrome browser binary to chrome webdriver in Python discussion.



来源:https://stackoverflow.com/questions/47656059/chrome-canary-headless-mode-does-not-work-on-windows10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!