I am trying to install python-selenium bindings by seeing here
When i am trying to import the following command, it is showing an error below
from selenium.firefox.webdriver import WebDriver
Result:
from selenium.firefox.webdriver import WebDriver
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named firefox.webdriver
I searched a lot to solve this, but i didn’t get the right example to do this, can anyone please provide me a way and an example on how to install python selenium bindings and why the above error is returned.
Thanks in advance……….
Edited :
I editing my code according to below answer,and tried the following , i got the below
>>> from selenium import webdriver
>>> driver = webdriver.Firefox()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 51, in __init__
self.binary, timeout),
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 44, in launch_browser
self._wait_until_connectable()
File "/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 81, in _wait_until_connectable
self._get_firefox_output())
selenium.common.exceptions.WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: *** LOG addons.xpi: startup\n*** LOG addons.xpi: checkForChanges\n*** LOG addons.xpi: Opening database\n*** LOG addons.xpi: No changes found\nFailed to dlopen /usr/lib/libX11.so.6\ndlerror says: /usr/lib/libX11.so.6: wrong ELF class: ELFCLASS32\n'
And also saying that there is some crash in firefox 1.0....
As stated on that page they have re-organized the package. Use the second code listing I have posted here.
EDIT (for new error):
Are you running this from a linux server with no X display? Firefox requires a display to render itself. Take a look at PyVirtualDisplay for running “headless” (without X).