我試圖安裝python-硒綁定安裝Python硒綁定,它顯示下面錯誤通過看<a href="http://code.google.com/p/selenium/wiki/PythonBindings" rel="nofollow">here</a></p> <p>當我試圖導入下面的命令在Fedora
from selenium.firefox.webdriver import WebDriver
錯誤結果:
from selenium.firefox.webdriver import WebDriver
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named firefox.webdriver
我搜索了很多解決這個問題,但我沒有得到正確的例子要做到這一點,任何人都可以請提供給我的方式和上一個例子如何安裝python selenium綁定以及爲什麼返回上述錯誤。
在此先感謝..........
編輯: 我按下面的答案編輯我的代碼,並試圖下面,我得到了下面
>>> 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'
並且還說有some crash in firefox 1.0....
我編輯了上面的代碼,我得到了我上面說過的arror。 –
檢查我的帖子上的編輯。如果你運行的服務器不是X Display,你將不得不使用PyVirtualDisplay這樣的工具來運行它。 –
我已經安裝了PyVirtualDisplay,我非常抱歉,我不知道如何使用X顯示器來運行,我做了與在該頁面中顯示的相同的操作,但仍然收到相同的錯誤。你可以請給我一個示例代碼如何刪除此錯誤。預先感謝 –