How to use save_all_ggr_logs method in toolium

Best Python code snippet using toolium_python

driver_wrappers_pool.py

Source:driver_wrappers_pool.py Github

copy

Full Screen

...124 # Close browser and stop driver if it must not be reused125 reuse_driver = cls.get_default_wrapper().should_reuse_driver(scope, test_passed, context)126 cls.stop_drivers(reuse_driver)127 cls.download_videos(test_name, test_passed, reuse_driver)128 cls.save_all_ggr_logs(test_name, test_passed)129 cls.remove_drivers(reuse_driver)130 @classmethod131 def stop_drivers(cls, maintain_default=False):132 """Stop all drivers except default if it should be reused133 :param maintain_default: True if the default driver should not be closed134 """135 # Exclude first wrapper if the driver must be reused136 driver_wrappers = cls.driver_wrappers[1:] if maintain_default else cls.driver_wrappers137 for driver_wrapper in driver_wrappers:138 if not driver_wrapper.driver:139 continue140 try:141 driver_wrapper.driver.quit()142 except Exception as e:143 driver_wrapper.logger.warning(144 "Capture exceptions to avoid errors in teardown method due to session timeouts: \n %s" % e)145 @classmethod146 def download_videos(cls, name, test_passed=True, maintain_default=False):147 """Download saved videos if video is enabled or if test fails148 :param name: destination file name149 :param test_passed: True if the test has passed150 :param maintain_default: True if the default driver should not be closed151 """152 # Exclude first wrapper if the driver must be reused153 driver_wrappers = cls.driver_wrappers[1:] if maintain_default else cls.driver_wrappers154 video_name = '{}_driver{}' if len(driver_wrappers) > 1 else '{}'155 video_name = video_name if test_passed else 'error_{}'.format(video_name)156 driver_index = 1157 for driver_wrapper in driver_wrappers:158 if not driver_wrapper.driver:159 continue160 try:161 # Download video if necessary (error case or enabled video)162 if (not test_passed or driver_wrapper.config.getboolean_optional('Server', 'video_enabled', False)) \163 and driver_wrapper.remote_node_video_enabled:164 driver_wrapper.utils.download_remote_video(driver_wrapper.server_type,165 video_name.format(name, driver_index))166 except Exception as exc:167 # Capture exceptions to avoid errors in teardown method due to session timeouts168 driver_wrapper.logger.warning('Error downloading videos: %s' % exc)169 driver_index += 1170 @classmethod171 def remove_drivers(cls, maintain_default=False):172 """Clean drivers list except default if it should be reused. Drivers must be closed before.173 :param maintain_default: True if the default driver should not be removed174 """175 cls.driver_wrappers = cls.driver_wrappers[0:1] if maintain_default else []176 @classmethod177 def save_all_webdriver_logs(cls, test_name, test_passed):178 """Get all webdriver logs of each driver and write them to log files179 :param test_name: test that has generated these logs180 :param test_passed: True if the test has passed181 """182 cls.save_all_webdriver_or_ggr_logs(test_name, test_passed, ggr=False)183 @classmethod184 def save_all_ggr_logs(cls, test_name, test_passed):185 """Get all GGR logs of each driver and write them to log files186 :param test_name: test that has generated these logs187 :param test_passed: True if the test has passed188 """189 cls.save_all_webdriver_or_ggr_logs(test_name, test_passed, ggr=True)190 @classmethod191 def save_all_webdriver_or_ggr_logs(cls, test_name, test_passed, ggr=False):192 """Get all webdriver or GGR logs of each driver and write them to log files193 :param test_name: test that has generated these logs194 :param test_passed: True if the test has passed195 :param ggr: True if driver should be ggr or selenoid196 """197 log_name = '{} [driver {}]' if len(cls.driver_wrappers) > 1 else '{}'198 driver_index = 1...

Full Screen

Full Screen

driver_manager.py

Source:driver_manager.py Github

copy

Full Screen

...59 cls.save_all_webdriver_logs(test_name, test_passed)60 reuse_driver = cls.get_default_wrapper().should_reuse_driver(scope, test_passed, context)61 cls.stop_drivers(reuse_driver)62 cls.download_videos(test_name, test_passed, reuse_driver)63 cls.save_all_ggr_logs(test_name, test_passed)64 cls.remove_drivers(reuse_driver)65 @classmethod66 def stop_drivers(cls, maintain_default=False):67 driver_wrappers = cls.driver_wrappers[1:] if maintain_default else cls.driver_wrappers68 close_driver = settings.settings.PYTALOS_RUN['close_webdriver']69 for driver_wrapper in driver_wrappers:70 if not driver_wrapper.driver:71 continue72 try:73 if close_driver:74 driver_wrapper.driver.quit()75 except Exception as e:76 driver_wrapper.logger.warn(77 f"Capture exceptions to avoid errors in teardown method due to session timeouts: \n {e}")78 @classmethod79 def download_videos(cls, name, test_passed=True, maintain_default=False):80 driver_wrappers = cls.driver_wrappers[1:] if maintain_default else cls.driver_wrappers81 video_name = '{}_driver{}' if len(driver_wrappers) > 1 else '{}'82 video_name = video_name if test_passed else 'error_{}'.format(video_name)83 driver_index = 184 for driver_wrapper in driver_wrappers:85 if not driver_wrapper.driver:86 continue87 try:88 if (not test_passed or driver_wrapper.config.getboolean_optional('Server', 'video_enabled', False)) \89 and driver_wrapper.remote_node_video_enabled:90 if driver_wrapper.server_type in ['ggr', 'selenoid']:91 from arc.contrib.utilities import get_valid_filename92 name = get_valid_filename(video_name.format(name, driver_index))93 Selenoid(driver_wrapper).download_session_video(name)94 elif driver_wrapper.server_type == 'grid':95 driver_wrapper.utils.download_remote_video(driver_wrapper.remote_node,96 driver_wrapper.session_id,97 video_name.format(name, driver_index))98 except Exception as exc:99 driver_wrapper.logger.warn(f"Error downloading videos: {exc}")100 driver_index += 1101 @classmethod102 def remove_drivers(cls, maintain_default=False):103 close_driver = settings.settings.PYTALOS_RUN['close_webdriver']104 if close_driver:105 cls.driver_wrappers = cls.driver_wrappers[0:1] if maintain_default else []106 @classmethod107 def save_all_webdriver_logs(cls, test_name, test_passed):108 log_name = '{} [driver {}]' if len(cls.driver_wrappers) > 1 else '{}'109 driver_index = 1110 for driver_wrapper in cls.driver_wrappers:111 if not driver_wrapper.driver or driver_wrapper.server_type in ['ggr', 'selenoid']:112 continue113 if driver_wrapper.config.getboolean_optional('Server', 'logs_enabled') or not test_passed:114 try:115 driver_wrapper.utils.save_webdriver_logs(log_name.format(test_name, driver_index))116 except Exception as exc:117 driver_wrapper.logger.warn(f"Error downloading webdriver logs: {exc}")118 driver_index += 1119 @classmethod120 def save_all_ggr_logs(cls, test_name, test_passed):121 log_name = '{} [driver {}]' if len(cls.driver_wrappers) > 1 else '{}'122 driver_index = 1123 for driver_wrapper in cls.driver_wrappers:124 if not driver_wrapper.driver or driver_wrapper.server_type not in ['ggr', 'selenoid']:125 continue126 try:127 if driver_wrapper.config.getboolean_optional('Server', 'logs_enabled') or not test_passed:128 from arc.contrib.utilities import get_valid_filename129 name = get_valid_filename(log_name.format(test_name, driver_index))130 Selenoid(driver_wrapper).download_session_log(name)131 except Exception as exc:132 driver_wrapper.logger.warn(f"Error downloading GGR logs: {exc}")133 driver_index += 1134 @staticmethod...

Full Screen

Full Screen

environment.py

Source:environment.py Github

copy

Full Screen

...86 # Force to reset driver before each scenario if it has @reset_driver tag87 if 'reset_driver' in scenario.tags:88 DriverWrappersPool.stop_drivers()89 DriverWrappersPool.download_videos('multiple tests', context.global_status['test_passed'])90 DriverWrappersPool.save_all_ggr_logs('multiple tests', context.global_status['test_passed'])91 DriverWrappersPool.remove_drivers()92 context.global_status['test_passed'] = True93 # Skip android_only or ios_only scenarios94 if 'android_only' in scenario.tags and context.driver_wrapper.is_ios_test():95 scenario.skip('Android scenario')96 return97 elif 'ios_only' in scenario.tags and context.driver_wrapper.is_android_test():98 scenario.skip('iOS scenario')99 return100 # Read @no_driver tag101 no_driver = 'no_driver' in scenario.tags or 'no_driver' in scenario.feature.tags102 bdd_common_before_scenario(context, scenario, no_driver)103 # Behave dynamic environment104 context.dyn_env.execute_before_scenario_steps(context)...

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