2017-04-06 88 views
3

我在打开一个新的chromedriver对象收到以下错误硒chromedriver错误。测试运行成功,但在我们的单元测试输出这个错误出现并且是不可取的。我想无论是解决错误或隐藏它,如果可能的话。的Python:在新的浏览器对象

我觉得一提的是从Python控制台运行时从Windows终端上运行脚本时,没有此输出只显示了它是非常重要的。

[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() 

我已经试过

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

也:

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

我也曾尝试输出重定向到NUL

$ python chromedriver_test.py > NUL

视窗7 Chromedriver = 2.29 的webdriver = 3.3.1

回答

7

尝试--disable-gpu开关。 Chrome浏览器似乎有一个问题,初始化GPU。我在Arch Linux上遇到了与Chromium(Version 57.0.2987.110)相同的问题,并且禁用了GPU,一切正常。

+0

如何使用'--disable-gpu'选项?你不知道什么意思'重新下载Chromedriver在https://chromedriver.storage.googleapis.com/index.html?路径= 2.28 /'。如何使用这个驱动程序。非常感谢! –

1

有我的代码。 Itz工作正常:

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)