Forums

Error in selenium import webdriver

Upon executing following code. the browser opens but then throws the error

from selenium import webdriver

from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()

browser = webdriver.Firefox()
browser.get('http://www.ubuntu.com/')

I am using firefox 31 . and latest version of selenium . I think I have installed all other dependencies

I am getting this error

Traceback (most recent call last):
  File "check.py", line 9, in <module>
    browser = webdriver.Firefox()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 61, in __init__
    self.binary, timeout),
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 51, in launch_browser
    self._wait_until_connectable()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 95, in _wait_until_connectable
    self.profile.path, self._get_firefox_output()))
selenium.common.exceptions.WebDriverException: Message: 'Can\'t load the profile. Profile Dir: /tmp/tmpbXfT3V Firefox output: Xlib:  extension "RANDR" missing on display ":1091".\n1409415495731\taddons.manager\tDEBUG\tLoaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]\n1409415495733\taddons.manager\tDEBUG\tLoaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]\n1409415495734\taddons.xpi\tDEBUG\tstartup\n1409415495751\taddons.xpi\tDEBUG\tcheckForChanges\n1409415495756\taddons.xpi\tDEBUG\tNo changes found\n'

[edited by admin: formatting]

Hi there -- is this running on PythonAnywhere? The installed versions of Selenium and Firefox should work fine.

ya .. This is running PythonAnywhere.

I am behind the proxy. Can this be reason?

I don't think that's it. How did you install Selenium and Firefox?

pip install -U selenium

sudo add-apt-repository ppa:ubuntu-mozilla-security/ppa sudo apt-get update sudo apt-get install firefox

It installed firefox 31 by default.

You can't use sudo on PythonAnywhere, so you can't change the installed firefox version. We've carefully chosen a version of Firefox (17) that works nicely with our default selenium (v 2.35) and with more recent ones (I just tested the latest selenium in a virtualenv). Later versions of Firefox had compatibility problems with our platform.

Are you sure you were running that code on PythonAnywhere?