How to use wait_func method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

unione_4.py

Source:unione_4.py Github

copy

Full Screen

...8990# render text91render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,92 ["Benvenuto all'esperimento comportamentale di Daniel Migliori"])93wait_func(clock)9495render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,96 [f"Il tuo codice identificativo e' {ID_NUMBER}"])97wait_func(clock)9899render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,100 ["Il gioco è composto da due sequenze", "di 5 minuti l’una"])101wait_func(clock)102103render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,104 ["Lo scopo di questo gioco è accumulare", "la maggior quantità di punti possibili"])105wait_func(clock)106107render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,108 ["Nel gioco appariranno due o tre quadrati", "di dimensione diversa"])109wait_func(clock)110111render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,112 ["I quadrati più grandi valgono più punti ", "rispetto a quelli più piccoli"])113wait_func(clock)114115render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,116 ["Per scegliere un quadrato premi la freccetta direzionale corrispondente ", "alla posizione del quadrato nello schermo"])117wait_func(clock)118119render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,120 ["Una volta scelto, il quadrato impiegherà alcuni secondi per scomparire"])121wait_func(clock)122123render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,124 ["Il numero dei secondi è indicato da una cifra accanto al quadrato"])125wait_func(clock)126127render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,128 ["Nella tua scelta dovrai tenere conto sia della dimensione", "che del tempo necessario per far scomparire il quadrato"])129wait_func(clock)130131render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,132 ["Quadrati più grandi daranno un punteggio maggiore"])133wait_func(clock)134135render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,136 ["Quadrati con tempi minori ti permetteranno di", " scegliere più volte prima dello scadere del tempo"])137wait_func(clock)138139render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,140 ["Il tuo punteggio totale sarà visibile nella parte bassa", "dello schermo mediante una barra rossa"])141wait_func(clock)142143render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,144 ["Inoltre il tuo punteggio totale diminuisce a ogni secondo", "quindi cerca di essere rapido nelle tue scelte"])145wait_func(clock)146147render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,148 ["Ora osserverai un esempio automatico, non devi fare nulla"])149wait_func(clock)150151# Tutorial Game152results_tutorial = tutorial_game(screen, (SCREEN_WIDTH, SCREEN_HEIGHT), OBJECT_SIZES, clock)153154# render text155render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,156 ["Ora comincia l’esperimento"])157wait_func(clock)158159render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,160 ["In questo primo gioco di allenamento sarà presente solo un quadrato"])161wait_func(clock)162163render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,164 ["Per scegliere il quadrato usa la freccetta sinistra"])165wait_func(clock)166167render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,168 ["Lo scopo è quello di provare i comandi e", " rendersi conto dei diversi parametri in gioco"])169wait_func(clock)170171render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,172 ["Il punteggio è ininfluente per questo primo gioco"])173wait_func(clock)174175render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,176 ["La durata di questo gioco è 1 minuto"])177wait_func(clock)178179render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,180 ["Per iniziare il gioco premi la barra spaziatrice"])181182# wait183wait_func(clock)184185# game186results_column1, results1 = game(screen, (SCREEN_WIDTH, SCREEN_HEIGHT), OBJECT_SIZES, clock, 1, tempo_di_gioco=60)187188# render text189render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,190 ["In questo secondo gioco saranno presenti 2 quadrati contemporaneamente"])191wait_func(clock)192193render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,194 ["Scegli quello che pensi ti permetterà di avere un punteggio finale più alto"])195wait_func(clock)196197render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,198 ["Per scegliere un quadrato premi la freccetta direzionale corrispondente ", "alla posizione del quadrato nello schermo (sinistra o destra)"])199wait_func(clock)200201render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,202 ["Una volta scelto, il quadrato impiegherà alcuni secondi per scomparire"])203wait_func(clock)204205render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,206 ["Il numero dei secondi è indicato da una cifra accanto al quadrato"])207wait_func(clock)208209render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,210 ["Nella tua scelta dovrai tenere conto sia della dimensione", "che del tempo necessario per far scomparire il quadrato"])211wait_func(clock)212213render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,214 ["Quadrati più grandi daranno un punteggio maggiore"])215wait_func(clock)216217render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,218 ["Quadrati con tempi minori ti permetteranno di", " scegliere più volte prima dello scadere del tempo"])219wait_func(clock)220221render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,222 ["Il tuo punteggio totale sarà visibile nella parte bassa", "dello schermo mediante una barra rossa"])223wait_func(clock)224225render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,226 ["Inoltre il tuo punteggio totale diminuisce a ogni secondo", "quindi cerca di essere rapido nelle tue scelte"])227wait_func(clock)228229render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,230 ["La durata di questo gioco è di 5 minuti"])231wait_func(clock)232233render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,234 ["Per iniziare il gioco premi la barra spaziatrice"])235236# wait237wait_func(clock)238239#game2240241results_column2, results2 = game(screen, (SCREEN_WIDTH, SCREEN_HEIGHT), OBJECT_SIZES, clock, 2, stimuli=stimuli, lista=lista)242243# results.to_excel("C:/Users/%s/Desktop/%s_2.xlsx" %(user, ID_NUMBER), index=False)244# results2.to_excel("%s_2.xlsx" %ID_NUMBER, index=False)245246#render text 3247render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,248 ["In questo terzo e ultimo gioco saranno presenti 3 quadrati contemporaneamente"])249wait_func(clock)250251render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,252 ["Scegli quello che pensi ti permetterà di avere un punteggio finale più alto"])253wait_func(clock)254255render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,256 ["Per scegliere un quadrato premi la freccetta direzionale corrispondente ", "alla posizione del quadrato nello schermo (sinistra, su o destra)"])257wait_func(clock)258259render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,260 ["Una volta scelto, il quadrato impiegherà alcuni secondi per scomparire"])261wait_func(clock)262263render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,264 ["Il numero dei secondi è indicato da una cifra accanto al quadrato"])265wait_func(clock)266267render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,268 ["Nella tua scelta dovrai tenere conto sia della dimensione", "che del tempo necessario per far scomparire il quadrato"])269wait_func(clock)270271render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,272 ["Quadrati più grandi daranno un punteggio maggiore"])273wait_func(clock)274275render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,276 ["Quadrati con tempi minori ti permetteranno di", " scegliere più volte prima dello scadere del tempo"])277wait_func(clock)278279render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,280 ["Il tuo punteggio totale sarà visibile nella parte bassa", "dello schermo mediante una barra rossa"])281wait_func(clock)282283render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,284 ["Inoltre il tuo punteggio totale diminuisce a ogni secondo", "quindi cerca di essere rapido nelle tue scelte"])285wait_func(clock)286287render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,288 ["La durata di questo gioco è di 5 minuti"])289wait_func(clock)290291render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,292 ["Per iniziare il gioco premi la barra spaziatrice"])293294# wait295wait_func(clock)296297# game 3298results_column3, results3 = game(screen, (SCREEN_WIDTH, SCREEN_HEIGHT), OBJECT_SIZES, clock, 3, stimuli=stimuli, lista=lista)299300render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,301 ["La prima parte dell’esperimento è conclusa", "Grazie della tua partecipazione"])302wait_func(clock)303304render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,305 [f"Il tuo codice identificativo e' {ID_NUMBER}", "Per favore scrivilo a parte prima di proseguire con l’esperimento"])306wait_func(clock)307308render_text(screen, SCREEN_WIDTH, SCREEN_HEIGHT,309 ["Premere la Barra Spaziatrice per chiudere il programma", "e passare al questionario"])310wait_func(clock)311312pygame.quit()313314# results.to_excel("C:/Users/%s/Desktop/%s.xls" %(user, ID_NUMBER), index=False)315# results3.to_excel("%s.xls" %ID_NUMBER, index=False)316317# Genera l'output318output_path = os.path.join(os.getcwd(), f"output_{ID_NUMBER}")319output_archive = os.path.join(os.getcwd(), f"output_archive_{ID_NUMBER}")320if not os.path.isdir(output_path):321 os.mkdir(output_path)322output_file1 = os.path.join(output_path, f"game1_{ID_NUMBER}.csv")323output_file2 = os.path.join(output_path, f"game2_{ID_NUMBER}.csv")324output_file3 = os.path.join(output_path, f"game3_{ID_NUMBER}.csv") ...

Full Screen

Full Screen

reserve.py

Source:reserve.py Github

copy

Full Screen

...31 except:32 print(f'{user.fullname}さんでログインに失敗しました。次の人に進みます。')33 driver = set_driver(URL)34 continue35 wait_func()36 # 目的を選択37 driver.find_element_by_partial_link_text(PURPOSE).click()38 # 予約日時を一つ一つ実行39 for num in range(DATETIMES.shape[0]):40 datetime = DATETIMES.loc[num]41 try:42 reserve(driver, datetime)43 print(f'{user.fullname}さんで{datetime.year}年{datetime.month}月{datetime.day}日の予約に成功しました。次の枠に進みます。')44 except:45 print(f'{user.fullname}さんで{datetime.year}年{datetime.month}月{datetime.day}日の予約に失敗しました。次の枠に進みます。')46 continue47 wait_func()48 try:49 logout(driver, user)50 print(f'{user.fullname}さんでログアウトしました。次の人に進みます。')51 except:52 print(f'{user.fullname}さんでログアウトに失敗しました。次の人に進みます。')53 driver = set_driver(URL)54 continue55 wait_func()56def set_driver(url):57 driver = webdriver.Chrome()58 driver.get(url)59 driver.switch_to.frame('MainFrame')60 driver.implicitly_wait(WAIT_LONG_TIME)61 return driver62def login(driver, user):63 driver.find_element_by_xpath("//input[@value='マイメニュー']").click()64 driver.find_element_by_name('txt_usr_cd').send_keys(user.user_id)65 driver.find_element_by_name('txt_pass').send_keys(user.password)66 driver.find_element_by_name('btn_ok').click()67 driver.find_element_by_name('btn_MoveMenu').click()68 return69def reserve(driver, datetime):70 # クリック71 driver.find_element_by_partial_link_text('施設、時間帯を').click()72 wait_func()73 # 施設選択74 Select(driver.find_element_by_name('lst_kaikan')).select_by_visible_text(FACILITY)75 wait_func()76 # 日時選択77 disp_date = driver.find_element_by_class_name('clsCalTitleYM').text78 # 年79 year_text = f'{datetime.year}年'80 if year_text not in disp_date:81 driver.find_element_by_link_text(year_text).click()82 wait_func()83 # 月84 month_text = f'{datetime.month}月'85 if month_text not in disp_date:86 driver.find_element_by_link_text(month_text).click()87 wait_func()88 # 日89 driver.find_element_by_link_text(str(datetime.day)).click()90 wait_func()91 # よくわからんけど一応92 alert_flg = False93 try:94 driver.find_element_by_xpath("//img[@alt=\"抽選予約\"]").is_displayed()95 except:96 alert_flg = True97 # 時間帯98 target = driver.find_element_by_name(f'ahref00000{datetime.time_code}000')99 target_text = target.find_element_by_tag_name('img').get_attribute('alt')100 if target_text != '抽選予約可能' and target_text != '抽選予約画面へ移動':101 raise Exception('抽選できません')102 target.click()103 # アラート対応104 if alert_flg:105 Alert(driver).accept()106 driver.find_element_by_name(f'ahref00000{datetime.time_code}000').click()107 wait_func()108 # コート全面を選択する処理109 win = driver.window_handles110 wait_func()111 driver.switch_to.window(win[1])112 wait_func()113 Select(driver.find_element_by_name('men_1_1')).select_by_visible_text('1')114 wait_func()115 driver.find_elements_by_name('btn_modoru')[0].click()116 wait_func()117 driver.switch_to.window(win[0])118 driver.switch_to.frame(driver.find_elements_by_xpath("//frame")[0])119 wait_func()120 driver.find_element_by_name('btn_ok').click()121 wait_func()122 driver.find_element_by_name('btn_next').click()123 wait_func()124 driver.find_element_by_name('btn_next').click()125 wait_func()126 driver.find_element_by_name('btn_cmd').click()127 wait_func()128 Alert(driver).accept()129 wait_func()130 return131def logout(driver, user):132 driver.find_element_by_name('btn_LogOut').click()133 return134def wait_func(time=WAIT_TIME):135 print('待機中...\r', end='')136 sleep(time)137 return138if __name__ == '__main__':...

Full Screen

Full Screen

minipr.py

Source:minipr.py Github

copy

Full Screen

1from tkinter import *2import time3import threading4def wait_func(timer=1):5 time.sleep(timer)6global dist7def run(list2=['A','B','C', 'D','E'], dist=[[0, 74, 4109, 3047, 2266],[74, 0, 4069, 2999, 2213],[4109, 4069, 0, 1172, 1972], [3047, 2999, 1172, 0, 816],[2266, 2213, 1972, 816, 0]],cities=[0,1,2,3,4,5,6]):8 boolean = False9 sample_copy = []10 for i in dist:11 extra_list = []12 for j in i:13 extra_list.append(j)14 sample_copy.append(extra_list)15 for j in dist:16 flag = False17 for i in j:18 if i != 0:19 flag = True20 break21 if flag:22 break23 else:24 boolean = True25 root = Tk()26 length = len(list2)27 for i in range(length-1, 6):28 list2.append(None)29 30 myCanvas = Canvas(root,height=500,width=500)31 myCanvas.pack() 32 def draw():33 list_of_nodes = []34 matrix = dist35 list_of_nodes.append(myCanvas.create_oval(225,100,275,150)) # A36 wait_func()37 myCanvas.create_text((225+275)/2,(100+150)/2,text=list2[0])38 wait_func()39 matrix[0][1] = myCanvas.create_line(140 ,175, 225, 125) # AB40 wait_func()41 list_of_nodes.append(myCanvas.create_oval(120,175,170,225)) # B42 wait_func()43 myCanvas.create_text((120+170)/2,(175+225)/2,text=list2[1])44 wait_func()45 46 matrix[1][2] = myCanvas.create_line(140 ,225, 140, 300) # BC47 wait_func()48 list_of_nodes.append(myCanvas.create_oval(120,300,170,350)) # C49 wait_func()50 myCanvas.create_text((120+170)/2,(300+350)/2,text=list2[2])51 wait_func()52 matrix[0][2] = myCanvas.create_line(250 ,150,170 ,325) # AC 53 wait_func()54 55 if list2[3] != None:56 matrix[2][3] = myCanvas.create_line(145 ,350,225, 400) # CD57 wait_func()58 list_of_nodes.append(myCanvas.create_oval(225,375,275,425)) # D59 wait_func()60 myCanvas.create_text((225+275)/2,(375+425)/2,text=list2[3])61 wait_func()62 matrix[0][3] = myCanvas.create_line(250 ,150, 250, 375) # AD63 wait_func()64 matrix[1][3] = myCanvas.create_line(170 ,200,250, 375) # BD65 wait_func()66 if list2[4] != None:67 matrix[3][4] = myCanvas.create_line( 250, 375,330, 200) # DE68 wait_func()69 list_of_nodes.append(myCanvas.create_oval(330,175,380,225)) # E70 wait_func()71 myCanvas.create_text((330+380)/2,(175+225)/2,text=list2[4])72 wait_func()73 matrix[0][4] = myCanvas.create_line(275,125,355,175) # AE74 wait_func()75 matrix[1][4] = myCanvas.create_line(170 ,200, 330, 200) # BE76 wait_func()77 matrix[2][4] = myCanvas.create_line(170 ,325,330, 200) # CE78 wait_func()79 if list2[5] != None:80 matrix[4][5] = myCanvas.create_line(355,225,355,300, tags="Hey") # EF81 wait_func()82 list_of_nodes.append(myCanvas.create_oval(330,300,380,350)) # F83 wait_func()84 myCanvas.create_text((330+380)/2,(300+350)/2,text=list2[5])85 wait_func()86 matrix[0][5] =myCanvas.create_line(250 ,150, 330, 325) # AF87 wait_func()88 matrix[1][5] = myCanvas.create_line(170 ,200,330, 325) # BF 89 wait_func()90 matrix[2][5] = myCanvas.create_line(170 ,325, 330, 325) # CF91 wait_func()92 matrix[3][5] = myCanvas.create_line(275, 400,355, 350) # DF93 wait_func()94 # o1.config(fill="blue")95 # myCanvas.create_text(375,250,text="Hey") # EF96 def path_len(path):97 return sum(dist[i][j] for i, j in zip(path, path[1:]))98 to_visit = set(range(len(dist)))99 state = {(i, frozenset([0, i])): [0, i] for i in range(1, len(dist[0]))}100 for _ in range(len(dist) - 2):101 next_state = {}102 for position, path in state.items():103 current_node, visited = position104 for node in to_visit - visited:105 new_path = path + [node]106 new_pos = (node, frozenset(new_path))107 if new_pos not in next_state or path_len(new_path) < path_len(next_state[new_pos]):108 next_state[new_pos] = new_path109 state = next_state110 shortest = min((path + [0] for path in state.values()), key=path_len)111 # y = 'path: {0}, length: {1}'.format(shortest, path_len(shortest))112 y = "Path: "113 ans = myCanvas.create_text(250, 450,text=y) 114 prev = shortest[0]115 count = 0116 for k in shortest:117 if prev < k:118 myCanvas.itemconfig(matrix[prev][k],fill="blue", width=2)119 count += sample_copy[prev][k]120 elif k < prev:121 myCanvas.itemconfig(matrix[k][prev],fill="blue", width=2)122 count += sample_copy[k][prev]123 myCanvas.itemconfig(list_of_nodes[k], fill='orange')124 wait_func(1)125 y += str(list2[k])126 prev = k127 wait_func(2)128 myCanvas.itemconfig(ans, text=y)129 wait_func(1)130 y += "-->"131 y = y.rstrip("-->")132 133 myCanvas.itemconfig(ans, text=y)134 length_of_shortest_path = "Minimum Distance: " + str(count)135 if boolean:136 length_of_shortest_path = "Minimum Distance: 0"137 myCanvas.create_text(250,480,text=length_of_shortest_path)138 139 root.after(1000,threading.Thread(target=draw).start())140 root.mainloop()141if __name__ == '__main__':...

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 robotframework-appiumlibrary 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