无法远程运行Selenium脚本

时间:2019-04-15 07:24:36

标签: python selenium selenium-webdriver

我有一个python硒脚本。我想在远程连接的PC上运行脚本。当我直接在该PC上运行脚本时,它就会运行。但是,当我远程运行同一脚本时,它会引发错误。

Traceback (most recent call last):
  File "crawling_script.py", line 14, in <module>
    driver = webdriver.Chrome(executable_path='/var/www/html/hariharan/health_grades/chromedriver')
  File "/var/www/html/hariharan/health_grades/env/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/var/www/html/hariharan/health_grades/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/var/www/html/hariharan/health_grades/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/var/www/html/hariharan/health_grades/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/var/www/html/hariharan/health_grades/env/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.4.0-145-generic x86_64)

请给我一个解决方案,以远程运行Selenium python脚本。 预先感谢。

1 个答案:

答案 0 :(得分:0)

尝试ssh -X,它将图形输出转发到本地计算机。