how to setup selenium python environment for firefox?

对着背影说爱祢 提交于 2019-12-04 06:24:27

As far as I understand, you want to develop in python, using selenium library and work with Firefox webdriver.

  1. install python (python3 already contains pip)
  2. install selenium (pip install selenium OR some IDEs like PyCharm propose to install libraries, just import selenium)
  3. download Mozilla webdriver
  4. enjoy!
IslamTaha

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()

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!