Best Python code snippet using Airtest
ui.py
Source: ui.py
...142 assert_value = False if self.assertion == 'assert_not_' else True143 if self.assertion:144 action = action_stack[-1]145 assert_result = self.obj == assert_value146 prev_selector_obj = self._get_selector_obj()147 # å¿
é¡»é¢å
å¤ææé对象æ¯å¦åå¨ï¼ä¸åå¨ç对象è°ç¨infoå±æ§æ¶ä¼æåºuiautomator.UiObjectNotFoundException148 # å 为å³ä½¿æ¯assert_not_checkedæ¶ï¼ä¹æ¯å¯ä»¥è·å对象infoç149 if prev_selector_obj.obj.exists:150 uiobj = prev_selector_obj.obj.info151 else:152 uiobj = None153 assert_action = self.assertion + action154 genlog('assert', [assert_action, prev_selector_obj.selectors, assert_result] + list(args), uiobj)155 if not assert_result:156 try:157 raise AutomatorAssertionFail('assert failed of {}, require {}, got {}'.format(assert_action, assert_value, self.obj))158 except AutomatorAssertionFail:159 log_error('assert', traceback.format_exc(), assert_action, prev_selector_obj.selectors, assert_result, *args, **kwargs)160 raise161 return None162 # handle selector expr163 if args or kwargs:164 if all([k in SELECTOR_ARGS for k in kwargs]):165 # get this select action name166 if len(action_stack) >= 1:167 action = action_stack[-1]168 else:169 action = 'global'170 # relative selector171 prev_selector_obj = self._get_selector_obj()172 if prev_selector_obj:173 uiobj = try_getattr(prev_selector_obj.obj, 'info', prev_selector_obj.select_action, prev_selector_obj.selectors)174 genlog('select', [prev_selector_obj.select_action, prev_selector_obj.selectors], uiobj)175 calling = try_call(self.obj, action, *args, **kwargs)176 ret = self.__class__(calling, self)177 ret.selectors = (args, kwargs) if args else kwargs178 ret.select_action = action179 return ret180 # å
¶ä»æä½çlogè®°å½181 action, params = None, None182 if args or kwargs:183 last_log = list(args) or kwargs.values()184 else:185 last_log = []186 if len(action_stack) >= 3 and action_stack[-3] in TERTIARY_ACTION:187 taction = TERTIARY_ACTION[action_stack[-3]]188 if action_stack[-2] in taction:189 saction = taction[action_stack[-2]]190 if action_stack[-1] in saction:191 action = action_stack[-3]192 params = action_stack[-2:] + last_log193 if len(action_stack) >= 2 and action_stack[-2] in SECONDARY_ACTIONS:194 secondary_action = SECONDARY_ACTIONS[action_stack[-2]]195 if action_stack[-1] in secondary_action:196 action = action_stack[-2]197 params = action_stack[-1:] + last_log198 if len(action_stack) >= 1 and action_stack[-1] in PRIMARY_ACTION:199 action = action_stack[-1]200 params = last_log201 if action:202 # selectæä½logè®°å½203 selector_obj = self._get_selector_obj()204 uiobj = None205 if selector_obj:206 uiobj = try_getattr(selector_obj.obj, 'info', selector_obj.select_action, selector_obj.selectors)207 genlog('select', [selector_obj.select_action, selector_obj.selectors], uiobj)208 genlog(action, params, uiobj)209 if not calling:210 calling = try_call(self.obj, 'action', *args, **kwargs)211 return self.__class__(calling, self)212 def __len__(self):213 return len(self.obj)214 def __nonzero__(self):215 """ python 2 only, for python 3, please override __bool__216 """217 return bool(self.obj)218 def __getitem__(self, item):219 return self.__class__(self.obj[item], self)220 def __iter__(self):221 objs, length = self, len(self)222 class Iter(object):223 def __init__(self):224 self.index = -1225 def next(self):226 self.index += 1227 if self.index < length:228 return objs[self.index]229 else:230 raise StopIteration()231 __next__ = next232 return Iter()233 def _get_selector_obj(self):234 # ä¸é¢çis not Noneçå¤ææ¹æ³æç¹ç¹æ®235 # å 为该类å®ç°äºbooléå¼è½¬æ¢æ¥å£ï¼å¦æä¸è¿æ ·å¤æçè¯ï¼å¨and表达å¼è¿åæ¶ï¼è¿ä¼èªå¨booléå¼è½¬æ¢ä¸æ¬¡236 # 导è´æ¡ä»¶å¤æéé¢æ237 ret = None238 if self.selectors:239 ret = self240 elif (self.parent and self.parent.selectors) is not None:241 ret = self.parent242 elif (self.parent and self.parent.parent and self.parent.parent.selectors) is not None:243 ret = self.parent.parent244 elif (self.parent and self.parent.parent and self.parent.parent.parent and self.parent.parent.parent.selectors) is not None:245 ret = self.parent.parent.parent246 return ret247 def end(self):...
Check out the latest blogs from LambdaTest on this topic:
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
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!!