Solved it by changing the permissions of the folder containing the Python script that called the webdriver from 755 to 757 (i.e., I gave write permissions to all users). I'm not sure whether this was a quirk of my situation because of something else I overlooked or whether there's actual insight to be gained here, but I'd say the take home lesson is if weird stuff is happening when working on an unfamiliar server, check the permissions.
Title says it all. I'm using webdriver on a remote webserver without a GUI. From the command line, I can do this and everything works fine:
from selenium import webdriver from pyvirtualdisplay import Display display = Display(visible=0, size=(800,600)) display.start() browser = webdriver.Firefox()
I.e., I can navigate the web, get urls, get source code, and everything else with the browser instance. But trying to execute a script on the server containing the same lines doesn't work. It might be relevant that the script is executed via PHP. Everything in the script works up until
browser = webdriver.Firefox() - that is, the imports and display stuff all work fine. It's just that last line; for some reason, the browser doesn't want to open when a script tries to do it. This makes no sense and I'm really stumped. Possible reasons/fixes? Maybe something to do with permissions?
Just to clarify, I'm doing this all on the remote server. By command line I'm using SSH with PUTTY, and when I try testing the script, I simply do it on the website.