Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myselfhimself/3d70180dfd388ccc25584be3b4984597 to your computer and use it in GitHub Desktop.
Save myselfhimself/3d70180dfd388ccc25584be3b4984597 to your computer and use it in GitHub Desktop.
Quick selenium test with old Firefox on Windows
# This helped me testing successfully python 2.7 x selenium x firefox 45 setup on windows 10
# Firefox 45 x86_46 was downloaded from http://ftp.mozilla.org/pub/firefox/nightly/2016/05/2016-05-11-00-15-09-mozilla-esr45/
# and installed with the custom wizard option allowing non-automatic background upgrades (helps if firefox is started manually by yourself)
# Mashup inspired by https://stackoverflow.com/a/47785513/420684 and https://selenium-python.readthedocs.io/getting-started.html
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities().FIREFOX
cap["marionette"] = False
driver = webdriver.Firefox(capabilities=cap) # The geckodriver.exe file should be in the Path environment variable
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment