I have a Python script that uses Selenium WebDriver (with PyVirtualDisplay as the display) to log into Flickr.
- http://pastebin.com/dqmf4Ecw (you’ll need to add your own Flickr credentials)
When I run it as myself on my Debian server, it works fine. (I’m a sudoer, but I don’t use sudo when running the script.)
When I run it as the user www-data
(which is what it’ll be running as eventually, because I want to trigger it from a Django website), I get two problems, one small, one big:
- (Small): the
webdriver.Firefox()
call takes 30–45 seconds to return, compared to 2 seconds when run as myself - (Big): the script fails to log into Flickr. In order to log in, I find the username and password fields on the Flickr signin page (http://www.flickr.com/signin/), and use
element.send_keys()
to enter the username and password. Although Selenium seems to find the elements (i.e. noNoSuchElementException
is thrown), the values do not get entered in the fields when the script is run aswww-data
(according to the screenshots I take usingbrowser.save_screenshot
), unlike when the script is run as myself.
Why does send_keys()
not work when the script is run as www-data
? (And is it related to the browser taking much longer to start?)