python - 在 ssh 中运行 Python Selenium webdriver

标签 python selenium ssh

我想在远程服务器上运行 selenium webdriver。我刚刚尝试了一个非常简单的脚本:

from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800,600))
display.start()
driver = webdriver.Chrome()
driver.get("http://www.google.com")
print browser.title
browser.quit()
display.stop()

错误是:

File "1.py", line 7, in <module>
driver = webdriver.Chrome()
File "/home/shunyang/.local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 61, in __init__
self.service.start()
File "/home/shunyang/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 85, in start
self.assert_process_still_running()
File "/home/shunyang/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 98, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException:
Message: Service chromedriver unexpectedly exited. 
Status code was: 1 

我想知道我的设置有什么问题以及如何解决这个问题。 谢谢!

最佳答案

我遇到了同样的问题。在尝试了很多东西之后,更新 chrome 解决了它:)

sudo apt-get install google-chrome-stable

关于python - 在 ssh 中运行 Python Selenium webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37799134/

相关文章:

python - Django 上传和处理没有数据保留的文件

java - Selenium WebDriver 下拉列表元素无法选择

java - 修改 Selenium Firefox 驱动程序的日志记录级别?

windows - 配置 Qt Creator 以使用 Git 的正确方法是什么?

python - 打印 python Post 请求

python - 如何从 `sympy.solve` 结果中消除负解?

python - Selenium / python : Closing Alert Window in Chrome

ssh - 期望ssh脚本(在远程计算机上执行命令)

linux - 如果服务器在我登录时打印字符串,如何在 MobaXterm 中打开 sftp 面板?

python - 在 Pygame 游戏中随机出现