How to setup selenium python environment for Firefox? I am using Firefox 50, selenium 3, python 3.5, I tried with many things binary and copying the geckodriver in environment path etc.
问题:
回答1:
As far as I understand, you want to develop in python, using selenium library and work with Firefox webdriver.
- install python (python3 already contains pip)
- install selenium (
pip install selenium
OR some IDEs like PyCharm propose to install libraries, just import selenium) - download Mozilla webdriver
- enjoy!
回答2:
The testing machine should have selenium V. 3.0.2, firefox V. 51.0.1 (Latest version) and geckodriver v. 0.14. If you are using linux please do the following steps:
[Look up the latest release on github and replace the wget link with that. Downloading and installing an outdating release may result in "buggy" behaviour.]
apt-get update
apt-get install firefox
pip3 install selenium==3.0.2
wget https://github.com/mozilla/geckodriver/releases/download/v0.14.0/geckodriver-vX.XX.0-linuxXX.tar.gz -O /tmp/geckodriver.tar.gz && tar -C /opt -xzf /tmp/geckodriver.tar.gz && chmod 755 /opt/geckodriver && ln -fs /opt/geckodriver /usr/bin/geckodriver && ln -fs /opt/geckodriver /usr/local/bin/geckodriver
To make sure that every thing is going well, check versions for all of them and make sure that its matching.
Here is an example to run
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://google.com')
print driver.title
driver.quit()
回答3:
1) in windows install python from : https://www.python.org/downloads/
2) then run pip install from command line: pip install selenium
3) download gecko/chrome/ie driver & add driver.exe path to PATH Variable. so need to setup path while running selenium driver.Firefox() / driver.Chrome() method.