简体   繁体   English

'selenium.common.exceptions.WebDriverException:消息:u'chrome无法访问

[英]'selenium.common.exceptions.WebDriverException: Message: u'chrome not reachable

I'm using webdriver to config a router, but when I run script: 我正在使用webdriver来配置路由器,但是当我运行脚本时:

from selenium import webdriver
self.driver = webdriver.Chrome()

It opens chrome and no response, and then raise exception: 它打开chrome并且没有响应,然后引发异常:

chrome not reachable. 铬无法到达。

My computer has two network cards, when I forbbiden one, it works well. 我的电脑有两张网卡,当我禁用一张网卡时,效果很好。
I don't konw why, please help! 我不知道为什么,请帮忙!

In pure case "chrome not reachable" means that Chrome binary can be started but debugging port is not reachable. 在纯粹的情况下,“chrome notachable”意味着可以启动Chrome二进制文件,但无法访问调试端口。

Debugging port is set by argument: --remote-debugging-port=12582 调试端口由参数设置: - remote-debugging-port = 12582

In my case it happens because some issues with sand-box: 在我的情况下,它发生是因为沙盒的一些问题:

ps afvvx | grep chrome

/opt/google/chrome/chrome --disable-background-networking --disable-client-side-phishing
21026 pts/2    S+     0:00      0    47  6008   100  0.0  |           \_ cat
21027 pts/2    S+     0:00      0    47  6008   100  0.0  |           \_ cat
21029 pts/2    Z+     0:00      0     0     0     0  0.0  |           \_ [chrome-sandbox] <defunct>

When I run /opt/google/chrome/chrome-sandbox 当我运行/ opt / google / chrome / chrome-sandbox时

# /opt/google/chrome/chrome-sandbox  -h
The setuid sandbox provides API version 1, but you need 0
Please read [https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment][1].

close: Bad file descriptor
Read on socketpair: Success

From url above I can't get what I'll to do to fix SUID SandBox, but it can be switched off by Chrome arg --disable-setuid-sandbox(sometimes with --no-sandbox): 从上面的url我无法得到我将要做的修复SUID SandBox,但可以通过Chrome arg --disable-setuid-sandbox(有时使用--no-sandbox)关闭它:

import time
from selenium import webdriver

from xvfbwrapper import Xvfb

vdisplay = Xvfb()
vdisplay.start()

from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-setuid-sandbox")

driver = webdriver.Chrome('/usr/local/sbin/chromedriver', chrome_options=chrome_options)  # Optional argument, if not specified will search path.
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()

vdisplay.stop()

Another case it's when some package is not installed like dbus-X11: 另一种情况是,当没有像dbus-X11那样安装某个软件包时:

/opt/google/chrome/google-chrome --no-sandbox --disable-setuid-sandbox --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.a0gQAp/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12512 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.dgq4j1 data:,
[39330:39330:0501/130308:ERROR:browser_main_loop.cc(185)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
Xlib:  extension "RANDR" missing on display ":1070".
Xlib:  extension "RANDR" missing on display ":1070".
[39330:39330:0501/130308:ERROR:desktop_window_tree_host_x11.cc(830)] Not implemented reached in virtual void views::DesktopWindowTreeHostX11::InitModalType(ui::ModalType)

(google-chrome:39330): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
/usr/bin/dbus-launch terminated abnormally without any error message
[39330:39353:0501/130308:ERROR:browser_gpu_channel_host_factory.cc(151)] Failed to create channel.

Just install it with: 只需安装它:

apt-get install dbus-X11

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python, selenium, chromedriver &#39;selenium.common.exceptions.WebDriverException: 消息:无法访问 u&#39;chrome - python, selenium, chromedriver 'selenium.common.exceptions.WebDriverException: Message: u'chrome not reachable selenium.common.exceptions.WebDriverException:消息:无法访问chrome - selenium.common.exceptions.WebDriverException: Message: chrome not reachable selenium.common.exceptions.WebDriverException:消息:即使更新后也无法访问chrome - selenium.common.exceptions.WebDriverException: Message: chrome not reachable even after updates Selenium.common.exceptions.WebDriverException:消息:未知错误:没有 chrome 二进制文件 - Selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary selenium.common.exceptions.WebDriverException:消息:使用 find_element_by_id Selenium 和 ChromeDriver 时出现 chrome 无法访问错误 - selenium.common.exceptions.WebDriverException: Message: chrome not reachable error while using find_element_by_id Selenium with ChromeDriver selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome无法以Selenium和RaspberryPi上的Chrome启动 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start with Selenium and Chrome on RaspberryPi selenium.common.exceptions.WebDriverException:消息:未知错误:无法使用 ChromeDriver Chrome Selenium 创建 Chrome 进程错误 - selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process error with ChromeDriver Chrome Selenium selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome无法启动:使用ChromeDriver Chrome和Selenium异常退出 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium selenium.common.exceptions.WebDriverException:消息:未知错误:无法使用带有Selenium Python的ChromeDriver Chrome创建Chrome进程 - selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process with ChromeDriver Chrome with Selenium Python selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:在 Python 中使用 ChromeDriver 和 Selenium 崩溃 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed with ChromeDriver and Selenium in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM