How to use _add_capabilities_from_properties method in toolium

Best Python code snippet using toolium_python

config_driver.py

Source:config_driver.py Github

copy

Full Screen

...70 capabilities['opera.arguments'] = '-fullscreen'71 elif driver_name == 'firefox':72 capabilities['firefox_profile'] = self._create_firefox_profile().encoded73 # Add custom driver capabilities74 self._add_capabilities_from_properties(capabilities, 'Capabilities')75 if driver_name == 'chrome':76 self._add_chrome_options_to_capabilities(capabilities)77 if driver_name in ('android', 'ios', 'iphone'):78 # Create remote appium driver79 self._add_capabilities_from_properties(capabilities, 'AppiumCapabilities')80 return appiumdriver.Remote(command_executor=server_url, desired_capabilities=capabilities)81 else:82 # Create remote web driver83 return webdriver.Remote(command_executor=server_url, desired_capabilities=capabilities)84 def _create_local_driver(self):85 """Create a driver in local machine86 :returns: a new local selenium driver87 """88 driver_name = self.utils.get_driver_name()89 if driver_name in ('android', 'ios', 'iphone'):90 # Create local appium driver91 driver = self._setup_appium()92 else:93 driver_setup = {94 'firefox': self._setup_firefox,95 'chrome': self._setup_chrome,96 'safari': self._setup_safari,97 'opera': self._setup_opera,98 'iexplore': self._setup_explorer,99 'edge': self._setup_edge,100 'phantomjs': self._setup_phantomjs101 }102 try:103 driver_setup_method = driver_setup[driver_name]104 except KeyError:105 raise Exception('Unknown driver {0}'.format(driver_name))106 # Get driver capabilities107 capabilities = self._get_capabilities_from_driver_type(driver_name)108 self._add_capabilities_from_properties(capabilities, 'Capabilities')109 # Create local selenium driver110 driver = driver_setup_method(capabilities)111 return driver112 @staticmethod113 def _get_capabilities_from_driver_type(driver_name):114 """Create initial driver capabilities115 :params driver_name: name of selected driver116 :returns: capabilities dictionary117 """118 if driver_name == 'firefox':119 capabilities = DesiredCapabilities.FIREFOX.copy()120 elif driver_name == 'chrome':121 capabilities = DesiredCapabilities.CHROME.copy()122 elif driver_name == 'safari':123 capabilities = DesiredCapabilities.SAFARI.copy()124 elif driver_name == 'opera':125 capabilities = DesiredCapabilities.OPERA.copy()126 elif driver_name == 'iexplore':127 capabilities = DesiredCapabilities.INTERNETEXPLORER.copy()128 elif driver_name == 'edge':129 capabilities = DesiredCapabilities.EDGE.copy()130 elif driver_name == 'phantomjs':131 capabilities = DesiredCapabilities.PHANTOMJS.copy()132 elif driver_name in ('android', 'ios', 'iphone'):133 capabilities = {}134 else:135 raise Exception('Unknown driver {0}'.format(driver_name))136 return capabilities137 def _add_capabilities_from_driver_type(self, capabilities):138 """Extract version and platform from driver type and add them to capabilities139 :param capabilities: capabilities dict140 """141 driver_type = self.config.get('Driver', 'type')142 try:143 capabilities['version'] = driver_type.split('-')[1]144 except IndexError:145 pass146 try:147 platforms_list = {'xp': 'XP',148 'windows_7': 'VISTA',149 'windows_8': 'WIN8',150 'windows_10': 'WIN10',151 'linux': 'LINUX',152 'android': 'ANDROID',153 'mac': 'MAC'}154 capabilities['platform'] = platforms_list.get(driver_type.split('-')[3], driver_type.split('-')[3])155 except IndexError:156 pass157 def _add_capabilities_from_properties(self, capabilities, section):158 """Add capabilities from properties file159 :param capabilities: capabilities object160 :param section: properties section161 """162 cap_type = {'Capabilities': 'server', 'AppiumCapabilities': 'Appium server'}163 try:164 for cap, cap_value in dict(self.config.items(section)).items():165 self.logger.debug("Added %s capability: %s = %s", cap_type[section], cap, cap_value)166 cap_value = cap_value if cap == 'version' else self._convert_property_type(cap_value)167 self._update_dict(capabilities, {cap: cap_value}, initial_key=cap)168 except NoSectionError:169 pass170 def _setup_firefox(self, capabilities):171 """Setup Firefox webdriver...

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