def get_local_driver(<EOL>browser_name, headless, proxy_string, proxy_auth,<EOL>proxy_user, proxy_pass, user_agent, disable_csp):
downloads_path = download_helper.get_downloads_folder()<EOL>download_helper.reset_downloads_folder()<EOL>if browser_name == constants.Browser.FIREFOX:<EOL><INDENT>try:<EOL><INDENT>try:<EOL><INDENT>profile = _create_firefox_profile(<EOL>downloads_path, proxy_string, user_agent, disable_csp)<EOL>firefox_capabilities = DesiredCapabilities.FIREFOX.copy()<EOL>firefox_capabilities['<STR_LIT>'] = True<EOL>options = webdriver.FirefoxOptions()<EOL>if headless:<EOL><INDENT>options.add_argument('<STR_LIT>')<EOL><DEDENT>if LOCAL_GECKODRIVER and os.path.exists(LOCAL_GECKODRIVER):<EOL><INDENT>make_driver_executable_if_not(LOCAL_GECKODRIVER)<EOL>firefox_driver = webdriver.Firefox(<EOL>firefox_profile=profile,<EOL>capabilities=firefox_capabilities,<EOL>options=options,<EOL>executable_path=LOCAL_GECKODRIVER)<EOL><DEDENT>else:<EOL><INDENT>firefox_driver = webdriver.Firefox(<EOL>firefox_profile=profile,<EOL>capabilities=firefox_capabilities,<EOL>options=options)<EOL><DEDENT><DEDENT>except WebDriverException:<EOL><INDENT>profile = _create_firefox_profile(<EOL>downloads_path, proxy_string, user_agent, disable_csp)<EOL>firefox_capabilities = DesiredCapabilities.FIREFOX.copy()<EOL>firefox_capabilities['<STR_LIT>'] = False<EOL>firefox_driver = webdriver.Firefox(<EOL>firefox_profile=profile, capabilities=firefox_capabilities)<EOL><DEDENT>return firefox_driver<EOL><DEDENT>except Exception as e:<EOL><INDENT>if headless:<EOL><INDENT>raise Exception(e)<EOL><DEDENT>return webdriver.Firefox()<EOL><DEDENT><DEDENT>elif browser_name == constants.Browser.INTERNET_EXPLORER:<EOL><INDENT>if not IS_WINDOWS:<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>")<EOL><DEDENT>from selenium.webdriver.ie.options import Options<EOL>ie_options = Options()<EOL>ie_options.ignore_protected_mode_settings = False<EOL>ie_options.ignore_zoom_level = True<EOL>ie_options.require_window_focus = False<EOL>ie_options.native_events = True<EOL>ie_options.full_page_screenshot = True<EOL>ie_options.persistent_hover = True<EOL>ie_capabilities = ie_options.to_capabilities()<EOL>if LOCAL_IEDRIVER and os.path.exists(LOCAL_IEDRIVER):<EOL><INDENT>make_driver_executable_if_not(LOCAL_IEDRIVER)<EOL>return webdriver.Ie(<EOL>capabilities=ie_capabilities,<EOL>executable_path=LOCAL_IEDRIVER)<EOL><DEDENT>else:<EOL><INDENT>return webdriver.Ie(capabilities=ie_capabilities)<EOL><DEDENT><DEDENT>elif browser_name == constants.Browser.EDGE:<EOL><INDENT>if not IS_WINDOWS:<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>")<EOL><DEDENT>edge_capabilities = DesiredCapabilities.EDGE.copy()<EOL>if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):<EOL><INDENT>make_driver_executable_if_not(LOCAL_EDGEDRIVER)<EOL>return webdriver.Edge(<EOL>capabilities=edge_capabilities,<EOL>executable_path=LOCAL_EDGEDRIVER)<EOL><DEDENT>else:<EOL><INDENT>return webdriver.Edge(capabilities=edge_capabilities)<EOL><DEDENT><DEDENT>elif browser_name == constants.Browser.SAFARI:<EOL><INDENT>return webdriver.Safari()<EOL><DEDENT>elif browser_name == constants.Browser.OPERA:<EOL><INDENT>if LOCAL_OPERADRIVER and os.path.exists(LOCAL_OPERADRIVER):<EOL><INDENT>make_driver_executable_if_not(LOCAL_OPERADRIVER)<EOL>return webdriver.Opera(executable_path=LOCAL_OPERADRIVER)<EOL><DEDENT>else:<EOL><INDENT>return webdriver.Opera()<EOL><DEDENT><DEDENT>elif browser_name == constants.Browser.PHANTOM_JS:<EOL><INDENT>with warnings.catch_warnings():<EOL><INDENT>warnings.simplefilter("<STR_LIT:ignore>", category=UserWarning)<EOL>return webdriver.PhantomJS()<EOL><DEDENT><DEDENT>elif browser_name == constants.Browser.GOOGLE_CHROME:<EOL><INDENT>try:<EOL><INDENT>chrome_options = _set_chrome_options(<EOL>downloads_path, headless, proxy_string, proxy_auth,<EOL>proxy_user, proxy_pass, user_agent, disable_csp)<EOL>if headless:<EOL><INDENT>if not proxy_auth:<EOL><INDENT>chrome_options.add_argument("<STR_LIT>")<EOL><DEDENT>chrome_options.add_argument("<STR_LIT>")<EOL>chrome_options.add_argument("<STR_LIT>")<EOL><DEDENT>if LOCAL_CHROMEDRIVER and os.path.exists(LOCAL_CHROMEDRIVER):<EOL><INDENT>make_driver_executable_if_not(LOCAL_CHROMEDRIVER)<EOL>return webdriver.Chrome(<EOL>executable_path=LOCAL_CHROMEDRIVER, options=chrome_options)<EOL><DEDENT>else:<EOL><INDENT>return webdriver.Chrome(options=chrome_options)<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>if headless:<EOL><INDENT>raise Exception(e)<EOL><DEDENT>if LOCAL_CHROMEDRIVER and os.path.exists(LOCAL_CHROMEDRIVER):<EOL><INDENT>make_driver_executable_if_not(LOCAL_CHROMEDRIVER)<EOL>return webdriver.Chrome(executable_path=LOCAL_CHROMEDRIVER)<EOL><DEDENT>else:<EOL><INDENT>return webdriver.Chrome()<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>" % browser_name)<EOL><DEDENT>
Spins up a new web browser and returns the driver.
Can also be used to spin up additional browsers for the same test.