Best Python code snippet using toolium_python
test_config_driver.py
Source:test_config_driver.py
...503 webdriver_mock.FirefoxProfile.assert_called_once_with(profile_directory='/tmp')504 webdriver_mock.FirefoxProfile().set_preference.assert_called_once_with('browser.download.folderList', 2)505 webdriver_mock.FirefoxProfile().update_preferences.assert_called_once_with()506 webdriver_mock.FirefoxProfile().add_extension.assert_called_once_with('resources/firebug-3.0.0-beta.3.xpi')507def test_add_firefox_arguments(config, utils):508 config.add_section('FirefoxArguments')509 config.set('FirefoxArguments', '-private', '')510 config_driver = ConfigDriver(config, utils)511 firefox_options = Options()512 config_driver._add_firefox_arguments(firefox_options)513 assert firefox_options.arguments == ['-private']514@mock.patch('toolium.config_driver.webdriver')515def test_create_chrome_options(webdriver_mock, config, utils):516 config.add_section('ChromePreferences')517 config.set('ChromePreferences', 'download.default_directory', '/tmp')518 config.add_section('ChromeMobileEmulation')519 config.set('ChromeMobileEmulation', 'deviceName', 'Google Nexus 5')520 config.add_section('ChromeArguments')521 config.set('ChromeArguments', 'lang', 'es')522 config_driver = ConfigDriver(config, utils)523 config_driver._create_chrome_options()524 webdriver_mock.ChromeOptions.assert_called_once_with()525 webdriver_mock.ChromeOptions().add_experimental_option.assert_has_calls(526 [mock.call('prefs', {'download.default_directory': '/tmp'}),...
config_driver.py
Source:config_driver.py
...182 firefox_options = FirefoxOptions()183 if self.config.getboolean_optional('Driver', 'headless'):184 self.logger.debug("Running Firefox in headless mode")185 firefox_options.add_argument('-headless')186 self._add_firefox_arguments(firefox_options)187 if firefox_binary:188 firefox_options.binary = firefox_binary189 log_path = os.path.join(DriverWrappersPool.output_directory, 'geckodriver.log')190 try:191 # Selenium 3192 return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,193 executable_path=gecko_driver, firefox_options=firefox_options, log_path=log_path)194 except TypeError:195 # Selenium 2196 return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,197 executable_path=gecko_driver, firefox_options=firefox_options)198 def _add_firefox_arguments(self, options):199 """Add Firefox arguments from properties file200 :param options: Firefox options object201 """202 try:203 for pref, pref_value in dict(self.config.items('FirefoxArguments')).items():204 pref_value = '={}'.format(pref_value) if pref_value else ''205 self.logger.debug("Added Firefox argument: %s%s", pref, pref_value)206 options.add_argument('{}{}'.format(pref, self._convert_property_type(pref_value)))207 except NoSectionError:208 pass209 def _create_firefox_profile(self):210 """Create and configure a firefox profile211 :returns: firefox profile212 """...
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!!