How to use _create_firefox_profile method in toolium

Best Python code snippet using toolium_python

browser_launcher.py

Source:browser_launcher.py Github

copy

Full Screen

2from selenium.common.exceptions import WebDriverException3from selenium.webdriver.common.desired_capabilities import DesiredCapabilities4from seleniumbase.core import download_helper5from seleniumbase.fixtures import constants6def _create_firefox_profile(downloads_path):7 profile = webdriver.FirefoxProfile()8 profile.set_preference("reader.parse-on-load.enabled", False)9 profile.set_preference("pdfjs.disabled", True)10 profile.set_preference(11 "security.mixed_content.block_active_content", False)12 profile.set_preference(13 "browser.download.manager.showAlertOnComplete", False)14 profile.set_preference("browser.download.panel.shown", False)15 profile.set_preference(16 "browser.download.animateNotifications", False)17 profile.set_preference("browser.download.dir", downloads_path)18 profile.set_preference("browser.download.folderList", 2)19 profile.set_preference(20 "browser.helperApps.neverAsk.saveToDisk",21 ("application/pdf, application/zip, application/octet-stream, "22 "text/csv, text/xml, application/xml, text/plain, "23 "text/octet-stream, "24 "application/"25 "vnd.openxmlformats-officedocument.spreadsheetml.sheet"))26 return profile27def get_driver(browser_name):28 '''29 Spins up a new web browser and returns the driver.30 Tests that run with pytest spin up the browser from here.31 Can also be used to spin up additional browsers for the same test.32 '''33 downloads_path = download_helper.get_downloads_folder()34 download_helper.reset_downloads_folder()35 if browser_name == constants.Browser.FIREFOX:36 try:37 try:38 # Use Geckodriver for Firefox if it's on the PATH39 profile = _create_firefox_profile(downloads_path)40 firefox_capabilities = DesiredCapabilities.FIREFOX.copy()41 firefox_capabilities['marionette'] = True42 firefox_driver = webdriver.Firefox(43 firefox_profile=profile, capabilities=firefox_capabilities)44 except WebDriverException:45 # Don't use Geckodriver: Only works for old versions of Firefox46 profile = _create_firefox_profile(downloads_path)47 firefox_capabilities = DesiredCapabilities.FIREFOX.copy()48 firefox_capabilities['marionette'] = False49 firefox_driver = webdriver.Firefox(50 firefox_profile=profile, capabilities=firefox_capabilities)51 return firefox_driver52 except:53 return webdriver.Firefox()54 if browser_name == constants.Browser.INTERNET_EXPLORER:55 return webdriver.Ie()56 if browser_name == constants.Browser.EDGE:57 return webdriver.Edge()58 if browser_name == constants.Browser.SAFARI:59 return webdriver.Safari()60 if browser_name == constants.Browser.PHANTOM_JS:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run toolium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful