I'm using webdriver to config a router, but when I run script:
from selenium import webdriver
self.driver = webdriver.Chrome()
It opens chrome and no response, and then raise exception:
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.
Debugging port is set by argument: --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 -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):
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With