How to use test_wait method in Airtest

Best Python code snippet using Airtest

mark_page.py

Source:mark_page.py Github

copy

Full Screen

...6 """7 设置标注形状为矩形8 :return:9 """10 def test_wait(x):11 self._params['condition_val'] = condition_val12 element_len = self.steps("page/mark_page.yaml", "click_play_condition")13 if element_len == 'False':14 a = self.steps("page/mark_page.yaml", "click_play_condition")15 return element_len > 016 self.wait_for_condition(test_wait)17 self.steps("page/mark_page.yaml", "set_mark_rectangle")18 def set_mark_polygon(self, condition_val):19 """20 设置标注形状为多边形21 :return:22 """23 def test_wait(x):24 self._params['condition_val'] = condition_val25 element_len = self.steps("page/mark_page.yaml", "click_play_condition")26 if element_len == 'False':27 a = self.steps("page/mark_page.yaml", "click_play_condition")28 return element_len > 029 self.wait_for_condition(test_wait)30 self.steps("page/mark_page.yaml", "set_mark_polygon")31 def set_mark_parallelogram(self, condition_val):32 """33 设置标注形状为平行四边形34 :return:35 """36 def test_wait(x):37 self._params['condition_val'] = condition_val38 element_len = self.steps("page/mark_page.yaml", "click_play_condition")39 if element_len == 'False':40 a = self.steps("page/mark_page.yaml", "click_play_condition")41 return element_len > 042 self.wait_for_condition(test_wait)43 self.steps("page/mark_page.yaml", "set_mark_parallelogram")44 def set_mark_ordered_parallelogram(self):45 """46 设置标注形状为有序平行四边形47 :return:48 """49 self.steps("page/mark_page.yaml", "set_mark_ordered_parallelogram")50 def mark_rectangle(self, position):51 """52 画一个预定义的矩形53 :return:54 """55 self._params["start_position"] = str(position['start_position'])56 self._params["end_position"] = str(position['end_position'])57 self.steps("page/mark_page.yaml", "mark_rectangle")58 def mark_polygon(self, position):59 """60 画一个预定义的多边形61 :return:62 """63 self._params["position1"] = str(position['position1'])64 self._params["position2"] = str(position['position2'])65 self._params["position3"] = str(position['position3'])66 self._params["position4"] = str(position['position4'])67 self._params["position5"] = str(position['position5'])68 self.steps("page/mark_page.yaml", "mark_polygon")69 def mark_parallelogram(self, position):70 """71 画一个预定义的平行四边形72 :return:73 """74 self._params["position1"] = str(position['position1'])75 self._params["position2"] = str(position['position2'])76 self._params["position3"] = str(position['position3'])77 self.steps("page/mark_page.yaml", "mark_parallelogram")78 def mark_ordered_parallelogram(self, position):79 """80 画一个预定义的有序平行四边形81 :return:82 """83 self._params["position1"] = str(position['position1'])84 self._params["position2"] = str(position['position2'])85 self._params["position3"] = str(position['position3'])86 self.steps("page/mark_page.yaml", "mark_ordered_parallelogram")87 def select_predefined(self):88 """89 新增一个框后,选择标签为预定义标签90 :return:91 """92 self.steps("page/mark_page.yaml", "select_predefined")93 def select_customize(self):94 """95 新增一个框后,选择标签为实时标签96 :return:97 """98 self.steps("page/mark_page.yaml", "select_customize")99 def select_predefined_val(self):100 """101 选择预定义标签属性102 :return:103 """104 pass105 def add_customize_val(self, add_value):106 """107 添加实时标签的值108 :return:109 """110 self._params["add_customize_val"] = str(add_value['add_value'])111 self.steps("page/mark_page.yaml", "add_customize_val")112 def select_ignore(self):113 """114 选择副属性选择忽略115 :return:116 """117 self.steps("page/mark_page.yaml", "select_ignore")118 def select_crowd(self):119 """120 选择副属性密集121 :return:122 """123 self.steps("page/mark_page.yaml", "select_crowd")124 def click_cancel(self):125 """126 新增框或修改框时点击取消127 :return:128 """129 self.steps("page/mark_page.yaml", "click_cancel")130 def click_submit(self, img_name):131 """132 新增框或修改框时点击确定133 :return:134 """135 self.steps("page/mark_page.yaml", "click_submit")136 self.driver.save_screenshot(f'result/{img_name}.png')137 def double_click(self, double_click):138 """139 双击140 :return:141 """142 self._params["double_click"] = double_click143 self.steps("page/mark_page.yaml", "double_click")144 def update_object_id(self, update_value):145 """146 修改框的对象ID147 :return:148 """149 self._params["update_object_id_val"] = str(update_value["updata_value"])150 self.steps("page/mark_page.yaml", "update_object_id")151 def update_mark_position(self, position):152 """153 修改框的位置154 :return:155 """156 self._params["start_position"] = str(position['start_position'])157 self._params["end_position"] = str(position['end_position'])158 self.steps("page/mark_page.yaml", "mark_rectangle")159 def click_all_cancel(self):160 """161 全部取消162 :return:163 """164 self.steps("page/mark_page.yaml", "click_all_cancel")165 def click_all_submit(self):166 """167 点击全部保存168 :return:169 """170 self.steps("page/mark_page.yaml", "click_all_submit")171 self.driver.save_screenshot('result/shortcut_key.png')172 def set_show_predefined_mark(self):173 """174 设置显示预定义标签的框175 :return:176 """177 self.steps("page/mark_page.yaml", "set_show_predefined_mark")178 def set_show_customize_mark(self, condition_val):179 """180 设置显示实时标签的框181 :return:182 """183 def test_wait(x):184 self._params['condition_val'] = condition_val185 element_len = self.steps("page/mark_page.yaml", "click_play_condition")186 if element_len == 'False':187 a = self.steps("page/mark_page.yaml", "click_play_condition")188 return element_len > 0189 self.wait_for_condition(test_wait)190 self.steps("page/mark_page.yaml", "set_show_customize_mark")191 def click_add_btn(self, condition_val):192 """193 点击新增按钮Q194 :return:195 """196 def test_wait(x):197 self._params['condition_val'] = condition_val198 element_len = self.steps("page/mark_page.yaml", "click_play_condition")199 if element_len == 'False':200 a = self.steps("page/mark_page.yaml", "click_play_condition")201 return element_len > 0202 self.wait_for_condition(test_wait)203 self.steps("page/mark_page.yaml", "click_add_btn")204 def select_del_mark(self, position, condition_val):205 """206 选择需要删除的框207 :return:208 """209 def test_wait(x):210 self._params['condition_val'] = condition_val211 element_len = self.steps("page/mark_page.yaml", "click_play_condition")212 if element_len == 'False':213 a = self.steps("page/mark_page.yaml", "click_play_condition")214 return element_len > 0215 self.wait_for_condition(test_wait)216 self._params["start_position"] = str(position['start_position'])217 self.steps("page/mark_page.yaml", "select_del_mark")218 def click_del_btn(self, condition_val):219 """220 点击删除按钮221 :return:222 """223 def test_wait(x):224 self._params['condition_val'] = condition_val225 element_len = self.steps("page/mark_page.yaml", "click_play_condition")226 if element_len == 'False':227 a = self.steps("page/mark_page.yaml", "click_play_condition")228 return element_len > 0229 self.wait_for_condition(test_wait)230 self.steps("page/mark_page.yaml", "click_del_btn")231 def click_previous_img_btn(self):232 """233 点击上一张234 :return:235 """236 self.wait_for_click((By.XPATH, "//*[@class='quick-btn-list']//button[3]"))237 self.steps("page/mark_page.yaml", "click_previous_img_btn")238 def click_next_img_btn(self):239 """240 点击下一张241 :return:242 """243 self.steps("page/mark_page.yaml", "click_next_img_btn")244 def click_hide_btn(self):245 """246 点击下一张247 :return:248 """249 self.wait_for_click((By.XPATH, "//*[@class='quick-btn-list']//button[5]"))250 self.steps("page/mark_page.yaml", "click_hide_btn")251 def click_reset_img_btn(self):252 """253 点击重置254 :return:255 """256 self.steps("page/mark_page.yaml", "click_reset_img_btn")257 def click_not_mark_btn(self):258 """259 在图片标注页,点击无法标注按钮260 :return:261 """262 self.wait_for_click((By.XPATH, "//*[@class='quick-btn-list']//button[7]"))263 self.steps("page/mark_page.yaml", "click_not_mark_btn")264 def moved_right(self):265 """266 鼠标移动至右侧,调出标注索引页267 :return:268 """269 self.steps("page/mark_page.yaml", "moved_right")270 def click_enter_not_mark_pic(self):271 """272 点击进入没有标注的图片273 :return:274 """275 self.steps("page/mark_page.yaml", "click_enter_not_mark_pic")276 def click_previous_page(self):277 """278 点击上一页279 :return:280 """281 self.steps("page/mark_page.yaml", "click_previous_page")282 def click_next_page(self):283 """284 点击下一页285 :return:286 """287 self.steps("page/mark_page.yaml", "click_next_page")288 def click_object_id(self):289 """290 点击对象ID,需要传入对象ID的xpath291 :return:292 """293 self.steps("page/mark_page.yaml", "click_object_id")294 def click_attribute(self):295 """296 点击属性,需要传入属性的Xpath297 :return:298 """299 self.steps("page/mark_page.yaml", "click_attribute")300 def click_play(self, condition_val):301 """302 点击播放303 :return:304 """305 def test_wait(x):306 self._params['condition_val'] = condition_val307 element_len = self.steps("page/mark_page.yaml", "click_play_condition")308 if element_len == 'False':309 a = self.steps("page/mark_page.yaml", "click_play_condition")310 return element_len > 0311 self.wait_for_condition(test_wait)312 self.steps("page/mark_page.yaml", "click_play")313 def click_begin_or_end(self):314 """315 点击开始或结束标记316 :return:317 """318 self.steps("page/mark_page.yaml", "click_begin_or_end")319 def click_previous_video(self, condition_val):320 """321 点击上一个视频322 :return:323 """324 def test_wait(x):325 self._params['condition_val'] = condition_val326 element_len = self.steps("page/mark_page.yaml", "click_play_condition")327 if element_len == 'False':328 a = self.steps("page/mark_page.yaml", "click_play_condition")329 return element_len > 0330 self.wait_for_condition(test_wait)331 self.steps("page/mark_page.yaml", "click_previous_video")332 def click_next_video(self):333 """334 点击下一个视频335 :return:336 """337 self.steps("page/mark_page.yaml", "click_next_video")338 def click_return(self):339 """340 点击快退341 :return:342 """343 self.steps("page/mark_page.yaml", "click_return")344 def click_forward(self):345 """346 点击快进347 :return: 348 """349 self.steps("page/mark_page.yaml", "click_forward")350 def click_not_mark_btn_video(self):351 """352 在视频标注页,点击无法标注按钮353 :return:354 """355 self.wait_for_click((By.XPATH, '//*[@class="quick-btn-list"]/button[7]'))356 self.steps("page/mark_page.yaml", "click_not_mark_btn_video")357 def update_video_label(self, condition_val):358 """359 更新视频的标签360 :return:361 """362 def test_wait(x):363 self._params['condition_val'] = condition_val364 element_len = self.steps("page/mark_page.yaml", "click_update_video_label")365 if element_len == 'False':366 a = self.steps("page/mark_page.yaml", "click_update_video_label")367 return element_len > 0368 self.wait_for_condition(test_wait)369 self.steps("page/mark_page.yaml", "update_video_label")370 def click_del_label(self, condition_val):371 """372 点击删除标注结果373 :return:374 """375 def test_wait(x):376 self._params['condition_val'] = condition_val377 element_len = self.steps("page/mark_page.yaml", "click_play_condition")378 if element_len == 'False':379 a = self.steps("page/mark_page.yaml", "click_play_condition")380 return element_len > 0381 self.wait_for_condition(test_wait)382 self.set_implicitly_wait(3)383 self.steps("page/mark_page.yaml", "click_del_label")384 def click_del_label_submit(self, condition_val):385 """386 点击删除标注结果确认按钮387 :return:388 """389 def test_wait(x):390 self._params['condition_val'] = condition_val391 element_len = self.steps("page/mark_page.yaml", "click_play_condition")392 if element_len == 'False':393 a = self.steps("page/mark_page.yaml", "click_play_condition")394 return element_len > 0395 self.wait_for_condition(test_wait)396 self.steps("page/mark_page.yaml", "click_del_label_submit")397 self.driver.save_screenshot('result/task_video.png')398 def click_add_step_len(self):399 """400 点击新增步长401 :return:402 """403 self.steps("page/mark_page.yaml", "click_add_step_len")

Full Screen

Full Screen

helper.py

Source:helper.py Github

copy

Full Screen

...21 global _failedNum, _testNum22 setcp1()23 if EUDIf()(condition):24 f_simpleprint("\x07 - [ OK ]\x04", testname)25 test_wait(0)26 if EUDElse()():27 f_simpleprint("\x08 - [FAIL]", testname)28 failedTestDb = DBString(testname)29 _failedTest[_failedNum] = failedTestDb30 _testFailed << 131 test_wait(24)32 EUDEndIf()33 resetcp()34 _testNum += 135 test_wait(0)36def test_equality(testname, real, expt):37 global _failedNum, _testNum38 real = Assignable2List(real)39 expt = Assignable2List(expt)40 setcp1()41 if EUDIf()([r == e for r, e in zip(real, expt)]):42 f_simpleprint("\x07 - [ OK ]\x04", testname)43 test_wait(0)44 if EUDElse()():45 f_simpleprint("\x08 - [FAIL]", testname)46 f_simpleprint(" \x03 - \x04 Output : ", *real)47 f_simpleprint(" \x03 - \x04 Expected : ", *expt)48 failedTestDb = DBString(testname)49 _failedTest[_failedNum] = failedTestDb50 _failedNum += 151 test_wait(24)52 EUDEndIf()53 resetcp()54 f_setcurpl(origcp)55 _testNum += 156def test_operator(testname, realf, exptf=None):57 if exptf is None:58 exptf = realf59 try:60 f = realf._bodyfunc61 except AttributeError:62 f = realf63 argcount = f.__code__.co_argcount64 @TestInstance65 def test_operator():66 inputs = [EUDVariable() for _ in range(argcount)]67 expt, real = [], []68 for i in range(20):69 rnums = [_random.randint(0, 0xFFFFFFFF) for _ in range(argcount)]70 SetVariables(inputs, rnums)71 real.append(realf(*inputs))72 expt.append(exptf(*rnums) & 0xFFFFFFFF)73 test_assert(74 "Operator test : %s" % testname, [r == e for r, e in zip(real, expt)]75 )76class expect_eperror:77 def __enter__(self):78 PushTriggerScope()79 def __exit__(self, type, e, traceback):80 PopTriggerScope()81 if isinstance(e, EPError):82 print(" - Error as expected : %s" % e)83 return True84 else:85 raise RuntimeError("EPError not thrown")86###############################################################87# Performance testing helper88###############################################################89perf_basecount = 20000090def test_perf(testname, func, count):91 starttm = f_dwread_epd(EPD(0x51CE8C))92 if EUDLoopN()(count):93 func()94 EUDEndLoopN()95 test_wait(0)96 endtm = f_dwread_epd(EPD(0x51CE8C))97 elapsedTime = starttm - endtm98 averageTime = elapsedTime // count99 setcp1()100 f_simpleprint(101 "\x03" * 150 + "[PERF] \x04%s \x03* %d \x05" % (testname, count),102 averageTime,103 "/",104 elapsedTime,105 spaced=False,106 )107 resetcp()108 test_wait(12)109###############################################################110def test_complete():111 setcp1()112 f_simpleprint("\x03" + "=" * 40)113 succNum = _testNum - _failedNum114 f_simpleprint("\x04 Test result : ", succNum, "/", _testNum, spaced=False)115 resetcp()116_testList = []117def TestInstance(func):118 print(" - Adding test instance %s" % func.__name__)119 _testList.append((func, func.__name__))120 return func121@EUDFunc122def _testmain():123 for testfunc, testname in _testList:124 _testFailed << 0125 f_simpleprint("\x03[TEST] 테스트를 진행합니다:", testname)126 testfunc()127 Trigger(_testFailed == 1, _failedNum.AddNumber(1))128 test_complete()129def test_runall(testname):130 LoadMap("outputmap/basemap/basemap_strx.scx")131 SaveMap("outputmap/test_%s.scx" % testname, _testmain)132def test_wait(time):133 DoActions(SetMemory(0x6509A0, SetTo, time))...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

...52 place.updateSunTimes()53 scheme = murklanScheme(place)54 lamp = Lamp(1)55 lamp.update(datetime.time(12, 10, 5, 0, tz), scheme[1][1][1])56 test_wait("Lamp expected to be OFF. Press enter to continue.")57 58 lamp.update(datetime.time(5, 50, 5, 0, tz), scheme[1][1][1])59 test_wait("Lamp expected to be OFF. Press enter to continue.")60 61 lamp.update(datetime.time(6, 30, 5, 0, tz), scheme[1][1][1])62 test_wait("Lamp expected to be ON. Press enter to continue.")63 64 lamp.update(datetime.time(8, 30, 5, 0, tz), scheme[1][1][1])65 test_wait("Lamp expected to be ON. Press enter to continue.")66 67 lamp.update(datetime.time(9, 10, 5, 0, tz), scheme[1][1][1])68 test_wait("Lamp expected to be OFF. Press enter to continue.")69 70 lamp.update(datetime.time(18, 40, 5, 0, tz), scheme[1][1][1]) # after sunset but within offset71 test_wait("Lamp expected to be OFF. Press enter to continue.")72 73 lamp.update(datetime.time(18, 59, 5, 0, tz), scheme[1][1][1])74 test_wait("Lamp expected to be ON. Press enter to continue.")75 76 lamp.update(datetime.time(22, 29, 5, 0, tz), scheme[1][1][1])77 test_wait("Lamp expected to be ON. Press enter to continue.")78 79 lamp.update(datetime.time(22, 30, 5, 0, tz), scheme[1][1][1])80 test_wait("Lamp expected to be OFF. Press enter to continue.")81def test_wait(s) :82 input(s)83 84 85def test_update() :86 nkp = Place(nkpCoord())87 nkp.updateSunTimes()88 myscheme = murklanScheme(nkp)89 update(myscheme)...

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 Airtest 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