How to use is_mobile_test method in toolium

Best Python code snippet using toolium_python

visual_test.py

Source:visual_test.py Github

copy

Full Screen

...124 def get_scrolls_size(self):125 scroll_x = 0126 scroll_y = 0127 if (self.driver_wrapper.config.get('Driver', 'type').split('-')[0] in ['chrome', 'iexplore'] and128 not self.driver_wrapper.is_mobile_test()):129 scroll_height = self.driver_wrapper.driver.execute_script("return document.body.scrollHeight")130 scroll_width = self.driver_wrapper.driver.execute_script("return document.body.scrollWidth")131 window_height = self.driver_wrapper.driver.execute_script("return window.innerHeight")132 window_width = self.driver_wrapper.driver.execute_script("return window.innerWidth")133 scroll_size = 21 if self.driver_wrapper.config.get('Driver', 'type').split('-')[0] == 'iexplore' else 17134 scroll_x = scroll_size if scroll_width > window_width else 0135 scroll_y = scroll_size if scroll_height > window_height else 0136 return {'x': scroll_x, 'y': scroll_y}137 def remove_scrolls(self, img):138 scrolls_size = self.get_scrolls_size()139 if scrolls_size['x'] > 0 or scrolls_size['y'] > 0:140 new_image_width = img.size[0] - scrolls_size['y']141 new_image_height = img.size[1] - scrolls_size['x']142 img = img.crop((0, 0, new_image_width, new_image_height))143 return img144 def mobile_resize(self, img):145 if self.driver_wrapper.is_ios_test() or self.driver_wrapper.is_android_web_test():146 scale = img.size[0] / self.utils.get_window_size()['width']147 if scale != 1:148 new_image_size = (int(img.size[0] / scale), int(img.size[1] / scale))149 img = img.resize(new_image_size, Image.ANTIALIAS)150 return img151 def get_element_box(self, web_element):152 if not self.driver_wrapper.is_mobile_test():153 scroll_x = self.driver_wrapper.driver.execute_script("return window.pageXOffset")154 scroll_x = scroll_x if scroll_x else 0155 scroll_y = self.driver_wrapper.driver.execute_script("return window.pageYOffset")156 scroll_y = scroll_y if scroll_y else 0157 offset_x = -scroll_x158 offset_y = -scroll_y159 else:160 offset_x = 0161 offset_y = self.utils.get_safari_navigation_bar_height()162 location = web_element.location163 size = web_element.size164 return (int(location['x']) + offset_x, int(location['y'] + offset_y),165 int(location['x'] + offset_x + size['width']), int(location['y'] + offset_y + size['height']))166 def crop_element(self, img, web_element):...

Full Screen

Full Screen

driver_wrapper.py

Source:driver_wrapper.py Github

copy

Full Screen

...112 if self.server_type == 'grid':113 self.remote_node_video_enabled = self.utils.is_remote_video_enabled(self.remote_node)114 else:115 self.remote_node_video_enabled = True if self.server_type in ['ggr', 'selenoid'] else False116 if self.is_mobile_test() and not self.is_web_test() and self.config.getboolean_optional('Driver',117 'appium_app_strings'):118 self.app_strings = self.driver.app_strings()119 if self.is_maximizable():120 bounds_x, bounds_y = self.get_config_window_bounds()121 self.driver.set_window_position(bounds_x, bounds_y)122 self.logger.debug('Window bounds: %s x %s', bounds_x, bounds_y)123 if maximize:124 window_width = self.config.get_optional('Driver', 'window_width')125 window_height = self.config.get_optional('Driver', 'window_height')126 if window_width and window_height:127 self.driver.set_window_size(window_width, window_height)128 else:129 self.driver.maximize_window()130 window_size = self.utils.get_window_size()131 self.logger.debug('Window size: %s x %s', window_size['width'], window_size['height'])132 self.update_visual_baseline()133 self.utils.discard_logcat_logs()134 if self.config.get('Driver', 'type') != 'ios':135 self.utils.set_implicitly_wait()136 return self.driver137 def get_config_window_bounds(self):138 bounds_x = int(self.config.get_optional('Driver', 'bounds_x') or 0)139 bounds_y = int(self.config.get_optional('Driver', 'bounds_y') or 0)140 monitor_index = int(self.config.get_optional('Driver', 'monitor') or -1)141 if monitor_index > -1:142 try:143 monitor = screeninfo.get_monitors()[monitor_index]144 bounds_x += monitor.x145 bounds_y += monitor.y146 except NotImplementedError:147 self.logger.warn('Current environment doesn\'t support get_monitors')148 return bounds_x, bounds_y149 def is_android_test(self):150 driver_name = self.config.get('Driver', 'type').split('-')[0]151 return driver_name == 'android'152 def is_ios_test(self):153 driver_name = self.config.get('Driver', 'type').split('-')[0]154 return driver_name in ('ios', 'iphone')155 def is_mobile_test(self):156 return self.is_android_test() or self.is_ios_test()157 def is_web_test(self):158 appium_browser_name = self.config.get_optional('AppiumCapabilities', 'browserName')159 return not self.is_mobile_test() or appium_browser_name not in (None, '')160 def is_android_web_test(self):161 return self.is_android_test() and self.is_web_test()162 def is_ios_web_test(self):163 return self.is_ios_test() and self.is_web_test()164 def is_maximizable(self):165 return not self.is_mobile_test()166 def should_reuse_driver(self, scope, test_passed, context=None):167 reuse_driver = self.config.getboolean_optional('Driver', 'reuse_driver')168 reuse_driver_session = self.config.getboolean_optional('Driver', 'reuse_driver_session')169 restart_driver_after_failure = (self.config.getboolean_optional('Driver', 'restart_driver_after_failure') or170 self.config.getboolean_optional('Driver', 'restart_driver_fail'))171 if context and scope == 'function':172 reuse_driver = reuse_driver or (hasattr(context, 'reuse_driver_from_tags')173 and context.pytalos.reuse_driver_from_tags)174 return (((reuse_driver and scope == 'function') or (reuse_driver_session and scope != 'session'))175 and (test_passed or not restart_driver_after_failure))176 def get_driver_platform(self):177 platform = ''178 if 'platform' in self.driver.desired_capabilities:179 platform = self.driver.desired_capabilities['platform']...

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