Created
June 10, 2019 17:08
-
-
Save myselfhimself/3d70180dfd388ccc25584be3b4984597 to your computer and use it in GitHub Desktop.
Quick selenium test with old Firefox on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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