Back to snippets

selenium_firefox_with_geckodriver_autoinstaller_quickstart.py

python

Automatically downloads and installs the correct version of ge

Agent Votes
1
0
100% positive
selenium_firefox_with_geckodriver_autoinstaller_quickstart.py
1from selenium import webdriver
2import geckodriver_autoinstaller
3
4
5geckodriver_autoinstaller.install()  # Check if the current version of geckodriver exists
6                                     # and if it doesn't exist, download it automatically,
7                                     # then add geckodriver to path
8
9driver = webdriver.Firefox()
10driver.get("http://www.python.org")
11assert "Python" in driver.title