Selenium 打开浏览器但 returns 出现错误
Selenium opens browser but returns with an error
关于运行这个代码
from selenium import webdriver
driver = webdriver.Chrome("/usr/bin/google-chrome")
打开带有新标签页的浏览器后出现此错误
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 96, in start
self.assert_process_still_running()
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited. Status code was: 0
之后我无法使用驱动程序变量,因为它 returns 一个 NameError。
我用 pip 安装了 selenium,我正在使用 python 3.5.3.
编辑 1:
我忘了说我正在使用 Ubuntu 17.04 zesty
当您使用 Selenium 3.x.x
以及最新的 Google Chrome
浏览器时,您必须下载 chromedriver.exe
from this location 将它放在你的系统中并通过参数executable_path
如下:
from selenium import webdriver
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
关于运行这个代码
from selenium import webdriver
driver = webdriver.Chrome("/usr/bin/google-chrome")
打开带有新标签页的浏览器后出现此错误
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 96, in start
self.assert_process_still_running()
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited. Status code was: 0
之后我无法使用驱动程序变量,因为它 returns 一个 NameError。
我用 pip 安装了 selenium,我正在使用 python 3.5.3.
编辑 1:
我忘了说我正在使用 Ubuntu 17.04 zesty
当您使用 Selenium 3.x.x
以及最新的 Google Chrome
浏览器时,您必须下载 chromedriver.exe
from this location 将它放在你的系统中并通过参数executable_path
如下:
from selenium import webdriver
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()