how to setup selenium python environment for firef

2020-07-08 07:30发布

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.

3条回答
甜甜的少女心
2楼-- · 2020-07-08 08:02

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.

查看更多
女痞
3楼-- · 2020-07-08 08:04

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!
查看更多
聊天终结者
4楼-- · 2020-07-08 08:10

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()
查看更多
登录 后发表回答