Best Python code snippet using selene_python
webdriver.py
Source:webdriver.py
...60class SafariExtended(Safari, WebDriverExtendedMixin):61 pass62class OperaExtended(Opera, WebDriverExtendedMixin):63 pass64def get_firefox(65 headless=False, extended=True, profile=None, preferences=None,66 proxy=5, image=True, sound=False, flash=True, **kwargs):67 """get firefox webdriver with option shortcuts"""68 opts = Options()69 opts.headless = headless70 if profile is None:71 profile = selenium.webdriver.FirefoxProfile()72 pref = profile.set_preference73 preferences = preferences or {}74 for k, v in preferences.items():75 pref(k, v)76 # http://kb.mozillazine.org/Network.proxy.type77 pref("network.proxy.type", proxy)78 if not image:79 pref('permissions.default.image', 2)80 if not flash:81 pref('dom.ipc.plugins.enabled.libflashplayer.so', 'false')82 if not sound:83 pref("media.volume_scale", "0.0")84 profile.update_preferences()85 cls = FirefoxExtended if extended else Firefox86 return cls(firefox_profile=profile, options=opts, **kwargs)87get_firfox_driver = get_firefox88def get_simplistic_driver():...
browser.py
Source:browser.py
...5from selenium.webdriver.firefox.options import Options6from webdriver_manager.chrome import ChromeDriverManager7from shutil import which8FIREFOXPATH = which("firefox")9def get_firefox(headless=False, *args, **kwargs):10 options = Options()11 options.binary = FIREFOXPATH12 if headless:13 options.add_argument("-headless")14 firefox_profile = FirefoxProfile()15 firefox_profile.set_preference("general.useragent.override",16 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:77.0) Gecko/20100101 Firefox/77.0")17 firefox_profile.set_preference("geo.prompt.testing", True)18 firefox_profile.set_preference("geo.prompt.testing.allow", True)19 binary = FirefoxBinary()20 return webdriver.Firefox(firefox_profile=firefox_profile, options=options, firefox_binary=binary)21def get_headless_firefox(*args, **kwargs):22 return get_firefox(headless=True, *args, **kwargs)23def get_chrome(headless=False, *args, **kwargs):24 chrome_options = webdriver.ChromeOptions()25 if headless:26 chrome_options.add_argument("--headless")27 chrome_options.add_argument('--no-sandbox')28 chrome_options.add_argument("--disable-gpu")29 chrome_options.add_argument("--enable-geolocation")30 return webdriver.Chrome(ChromeDriverManager().install(), chrome_options=chrome_options)31def get_headless_chrome(*args, **kwargs):32 return get_chrome(headless=True, *args, **kwargs)33_BROWSER_PROFILES = {34 "firefox": get_firefox,35 "chrome": get_chrome,36 "headless_firefox": get_headless_firefox,...
main.py
Source:main.py
...5logger = Logger()6webDrivers = WebDrivers()7speedTest = SpeedTestPl(webDrivers.get_edge(), logger)8speedTest.scenario_1()9speedTest = SpeedTestPl(webDrivers.get_firefox(), logger)10speedTest.scenario_1()11speedTest = SpeedTestPl(webDrivers.get_chrome(), logger)12speedTest.scenario_1()13speedTest = SpeedTestPl(webDrivers.get_edge(), logger)14speedTest.scenario_2()15speedTest = SpeedTestPl(webDrivers.get_firefox(), logger)16speedTest.scenario_2()17speedTest = SpeedTestPl(webDrivers.get_chrome(), logger)18speedTest.scenario_2()19kangur = Kangurkrakowpl(webDrivers.get_edge(), logger)20kangur.scenario_1()21kangur = Kangurkrakowpl(webDrivers.get_firefox(), logger)22kangur.scenario_1()23kangur = Kangurkrakowpl(webDrivers.get_chrome(), logger)24kangur.scenario_1()25kangur = Kangurkrakowpl(webDrivers.get_edge(), logger)26kangur.scenario_2()27kangur = Kangurkrakowpl(webDrivers.get_firefox(), logger)28kangur.scenario_2()29kangur = Kangurkrakowpl(webDrivers.get_chrome(), logger)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!