I am trying to launch a python script, containing selenium webdriver usage, over SSH using PuTTY. When running the command "sudo python3.4 [filepath].py" in the SSH terminal the "connection refused" error is raised, but when running the same command on the server terminal it works as it should.
The server is a Raspberry pi running Raspbian and is using geckodriver for the webdriver. The computer connecting to is using SSH is running Windows 10.
I have tried typing "export DISPLAY=:0" before running the python script. I also tried running the command trough gnome-terminal, hoping it would force the pi into loading the gui as I thought that the selenium driver being a graphical one might be part of the problem.
I am very new to SSH:ing and still fairly new to selenium.
To make it simpler than my actual program, this is just a script to launch selenium which still shows the same problem.
from selenium import webdriver
driver = webdriver.Firefox(executable_path=r'/home/pi/Downloads/gecko3/geckodriver')
driver.get('www.google.com')
driver.quit()
The output (coming into my SSH-client) is as follows:
Traceback (most recent call last):
File "/home/pi/Desktop/webtest.py", line 3, in <module>
driver = webdriver.Firefox(executable_path=r'/home/pi/Downloads/gecko3/geckodriver')
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: connection refused
Any help would be greatly appreciated