How to use _convert_property_type method in toolium

Best Python code snippet using toolium_python

driver_capabilities.py

Source: driver_capabilities.py Github

copy

Full Screen

...29 capabilities_type = {'Capabilities': 'server', 'AppiumCapabilities': 'Appium server'}30 try:31 for cap, cap_value in dict(base_config.config.items(section)).items():32 base_config.logger.debug(f"Added {capabilities_type[section]} capability: {cap} = {cap_value}")33 capabilities[cap] = cap_value if cap == 'version' else _convert_property_type(cap_value)34 except NoSectionError:35 pass36def _convert_property_type(value):37 if value in ('true', 'True'):38 return True39 elif value in ('false', 'False'):40 return False41 elif str(value).startswith('{') and str(value).endswith('}'):42 return ast.literal_eval(value)43 else:44 try:45 return int(value)46 except ValueError:47 return value48def add_firefox_arguments(options, base_config):49 try:50 for preference, preference_value in dict(base_config.config.items('FirefoxArguments')).items():51 preference_value = '={}'.format(preference_value) if preference_value else ''52 base_config.logger.debug(f"Added Firefox argument: {preference} = {preference_value}")53 options.add_argument('{}{}'.format(preference, _convert_property_type(preference_value)))54 except NoSectionError:55 pass56def create_firefox_profile(base_config):57 profile_directory = base_config.config.get_optional('Firefox', 'profile')58 if profile_directory:59 base_config.logger.debug(f"Using Firefox profile: {profile_directory}")60 profile = webdriver.FirefoxProfile(profile_directory=profile_directory)61 profile.native_events_enabled = True62 try:63 for preference, preference_value in dict(base_config.config.items('FirefoxPreferences')).items():64 base_config.logger.debug(f"Added Firefox preference: {preference} = {preference_value}")65 profile.set_preference(preference, _convert_property_type(preference_value))66 profile.update_preferences()67 except NoSectionError:68 pass69 try:70 for preference, preference_value in dict(base_config.config.items('FirefoxExtensions')).items():71 base_config.logger.debug(f"Added Firefox extension: {preference} = {preference_value}")72 profile.add_extension(preference_value)73 except NoSectionError:74 pass75 return profile76def create_chrome_options(base_config):77 options = webdriver.ChromeOptions()78 if base_config.config.getboolean_optional('Driver', 'headless'):79 base_config.logger.debug("Running Chrome in headless mode")80 options.add_argument('--headless')81 if os.name == 'nt':82 options.add_argument('--disable-gpu')83 add_chrome_options(options, 'prefs', base_config)84 add_chrome_options(options, 'mobileEmulation', base_config)85 add_chrome_arguments(options, base_config)86 return options87def add_chrome_options(options, option_name, base_config):88 options_conf = {89 'prefs': {90 'section': 'ChromePreferences',91 'message': 'preference'92 },93 'mobileEmulation': {94 'section': 'ChromeMobileEmulation',95 'message': 'mobile emulation option'96 }97 }98 option_value = dict()99 try:100 for key, value in dict(base_config.config.items(options_conf[option_name]['section'])).items():101 base_config.logger.debug("Added chrome %s: %s = %s", options_conf[option_name]['message'], key, value)102 option_value[key] = _convert_property_type(value)103 if len(option_value) > 0:104 options.add_experimental_option(option_name, option_value)105 except NoSectionError:106 pass107def add_chrome_arguments(options, base_config):108 try:109 for preference, preference_value in dict(base_config.config.items('ChromeArguments')).items():110 preference_value = '={}'.format(preference_value) if preference_value else ''111 base_config.logger.debug(f"Added Chrome argument: {preference} = {preference_value}")112 options.add_argument('{}{}'.format(preference, _convert_property_type(preference_value)))113 except NoSectionError:...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Starting & growing a QA Testing career

The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.

Your Favorite Dev Browser Has Evolved! The All New LT Browser 2.0

We launched LT Browser in 2020, and we were overwhelmed by the response as it was awarded as the #5 product of the day on the ProductHunt platform. Today, after 74,585 downloads and 7,000 total test runs with an average of 100 test runs each day, the LT Browser has continued to help developers build responsive web designs in a jiffy.

Six Agile Team Behaviors to Consider

Are members of agile teams different from members of other teams? Both yes and no. Yes, because some of the behaviors we observe in agile teams are more distinct than in non-agile teams. And no, because we are talking about individuals!

The Art of Testing the Untestable

It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?

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