Created
October 24, 2019 16:03
-
-
Save swang373/53a8f54c78b33acc822c20af5e6cd349 to your computer and use it in GitHub Desktop.
Running a headless Firefox browser using Selenium webdriver
This file contains hidden or 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
from selenium import webdriver | |
def main(): | |
# Setup options to run Firefox in headless mode. | |
firefox_options = webdriver.FirefoxOptions() | |
firefox_options.headless = True | |
# Open a Firefox browser and check the Python official site. | |
driver = webdriver.Firefox(options=firefox_options) | |
# If there's lots of dynamic content, have the browser wait a few seconds. | |
driver.implicitly_wait(5) | |
driver.get('https://www.python.org') | |
assert "Python" in driver.title | |
driver.close() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment