Python: selenium-chromedriver error on new browser object

雨燕双飞 提交于 2019-12-23 18:09:54

问题


I am receiving the below error upon opening a new chromedriver object. The tests run successfully, but this error shows up in our UnitTest output and is undesirable. I would like to either resolve the error or hide it, if possible.

I feel it is important to mention that this output only shows up when running the script from the Windows terminal, not when run from the Python Console.

[0406/170246.792:ERROR:child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain

chromedriver_test.py:

from selenium import webdriver

webdriver.Chrome()

I have tried

service_args=["--silent", "--log-level=0", --"disable-extensions", --"log-path=/PATH/TO/LOGS"]

also:

sys.stdout = open(os.devnull, 'w')
sys.stderr = open(os.devnull, 'w')

I have also tried redirecting the output to NUL

$ python chromedriver_test.py > NUL

Windows 7 Chromedriver=2.29 Webdriver=3.3.1


回答1:


Try the --disable-gpu switch. Chrome seems to have a problem with initializing the GPU. I had the same issue with Chromium (Version 57.0.2987.110) on my Arch Linux and with disabling the GPU everything works fine again.




回答2:


This is a bug of Chrome

Maybe you should use another brower or another version.

See more here:

Strange error in selenium after upgrading to chromedriver 2.28 needed for chrome 57




回答3:


There is my code. Itz works fine:

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

class MyLib(object):
    def __init__(self):
        chrome_options = Options()
        chrome_options.add_argument('--disable-gpu')
        self.driver = webdriver.Chrome(chrome_options=chrome_options)


来源:https://stackoverflow.com/questions/43266033/python-selenium-chromedriver-error-on-new-browser-object

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