Best Python code snippet using pytest-mozwebqa_python
osx_chrome_driver.py
Source:osx_chrome_driver.py
...12 self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)13 def launch_driver(self, url, options, browser_build_path):14 import webkitpy.thirdparty.autoinstalled.selenium15 from selenium import webdriver16 chrome_options = create_chrome_options()17 if browser_build_path:18 app_path = os.path.join(browser_build_path, self.app_name)19 binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)20 chrome_options.binary_location = binary_path21 driver_executable = self.webdriver_binary_path22 driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable)23 self._launch_webdriver(url=url, driver=driver)24 return driver25class OSXChromeCanaryDriver(OSXBrowserDriver):26 process_name = 'Google Chrome Canary'27 browser_name = 'chrome-canary'28 app_name = 'Google Chrome Canary.app'29 def launch_url(self, url, options, browser_build_path):30 args_with_url = self._insert_url(create_args(), 2, url)31 self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)32 def launch_driver(self, url, options, browser_build_path):33 import webkitpy.thirdparty.autoinstalled.selenium34 from selenium import webdriver35 chrome_options = create_chrome_options()36 if not browser_build_path:37 browser_build_path = '/Applications/'38 app_path = os.path.join(browser_build_path, self.app_name)39 binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)40 chrome_options.binary_location = binary_path41 driver_executable = self.webdriver_binary_path42 driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable)43 self._launch_webdriver(url=url, driver=driver)44 return driver45def create_args():46 args = ['--args', '--homepage', create_window_size_arg()]47 return args48def create_chrome_options():49 from selenium.webdriver.chrome.options import Options50 chrome_options = Options()51 chrome_options.add_argument("--disable-web-security")52 chrome_options.add_argument("--user-data-dir")53 chrome_options.add_argument("--disable-extensions")54 chrome_options.add_argument(create_window_size_arg())55 return chrome_options56def create_window_size_arg():57 window_size_arg = '--window-size={width},{height}'.format(width=int(OSXBrowserDriver._screen_size().width), height=int(OSXBrowserDriver._screen_size().height))...
driver_factory.py
Source:driver_factory.py
...19 return self.create_firefox_driver()20 elif name == 'firefox_remote':21 return self.create_remote_firefox_driver()22 23 def create_chrome_options(self):24 chrome_options = webdriver.chrome.options.Options()25 chrome_options.experimental_options["prefs"] = {}26 return chrome_options27 def create_chrome_driver(self):28 chrome_options = self.create_chrome_options()29 return webdriver.Chrome(options=chrome_options)30 def create_remote_chrome_driver(self):31 host = self._config['web_driver']['remote']['uri']32 driver = webdriver.Remote(command_executor=f"{host}/wd/hub",options=self.create_chrome_options())33 return driver34 35 def create_firefox_driver(self):36 raise NotImplementedError37 38 def create_remote_firefox_driver(self):...
helpers.py
Source:helpers.py
...9 def __enter__(self):10 return self.driver11 def __exit__(self, exc_type, exc_val, exc_tb):12 self.driver.quit()13def create_chrome_options():14 if platform.system() == 'Linux':15 opts = Options()16 opts.add_argument('--headless')17 opts.add_argument('--no-sandbox')18 opts.add_argument('--disable-dev-shm-usage')19 return opts20 else:21 opts = Options()22 return opts...
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!!