Best Python code snippet using toolium_python
visual_test.py
Source:visual_test.py
...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:...
test_driver_wrapper.py
Source:test_driver_wrapper.py
...188 driver_wrapper.config.set('AppiumCapabilities', 'app', appium_app)189 if appium_browser_name is not None:190 driver_wrapper.config.set('AppiumCapabilities', 'browserName', appium_browser_name)191 assert driver_wrapper.is_web_test() == is_web192 assert driver_wrapper.is_android_web_test() == is_android_web193 assert driver_wrapper.is_ios_web_test() == is_ios_web194@pytest.mark.parametrize("driver_type, is_maximizable", maximizable_drivers)195def test_is_maximizable(driver_type, is_maximizable, driver_wrapper):196 driver_wrapper.config.set('Driver', 'type', driver_type)197 assert driver_wrapper.is_maximizable() == is_maximizable198# (reuse_driver, reuse_driver_session, restart_driver_after_failure, restart_driver_fail,199# reuse_driver_from_tags, scope, test_passed, expected_should_reuse_driver)200should_be_reused = (201 ('true', 'true', 'true', 'true', True, 'function', True, True), # all = true202 # reuse_driver203 ('true', 'false', 'false', 'false', False, 'function', True, True), # reuse = true, function204 ('true', 'false', 'false', 'false', False, 'module', True, False), # reuse = true, module205 ('true', 'false', 'false', 'false', False, 'session', True, False), # reuse = true, session206 ('false', 'false', 'false', 'false', False, 'function', True, False), # reuse = false...
driver_wrapper.py
Source:driver_wrapper.py
...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'))...
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!!