Skip to content

Instantly share code, notes, and snippets.

@andreyuhai
Last active September 14, 2020 20:32
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 andreyuhai/ccbef849d0bf6e3ffabfdc7511af8422 to your computer and use it in GitHub Desktop.
Save andreyuhai/ccbef849d0bf6e3ffabfdc7511af8422 to your computer and use it in GitHub Desktop.
from vfs_appointment_finder import utils
class TestUtils:
def test_initialize_firefox_webdriver(self):
fox = utils.initialize_webdriver('firefox')
assert type(fox) == utils.webdriver.firefox.webdriver.WebDriver
fox.quit()
def test_initialize_chrome_webdriver(self):
chrome = utils.initialize_webdriver('chrome')
assert type(chrome) == utils.webdriver.chrome.webdriver.WebDriver
chrome.quit()
def initialize_webdriver(driver):
"""Initialize a webdriver and return it.
:param browser: this specifies the type of the browser, either chrome or firefox.
If it is anything else than 'firefox' then a Chrome browser will be initalized.
"""
if driver == 'firefox':
options = webdriver.firefox.options.Options()
options.headless = True
return webdriver.Firefox(options=options)
options = webdriver.chrome.options.Options()
options.headless = True
return webdriver.Chrome(options=options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment