Best Python code snippet using robotframework-appiumlibrary_python
test_enjoyball.py
Source:test_enjoyball.py
...40 def test_list_first(self):41 list_view=self.driver.find_element_by_id("com.example.lenovo.enjoyball:id/lv_time_demand")42 list_items = list_view.find_elements_by_class_name("android.widget.LinearLayout")43 list_items[0].click()44 self.driver.press_keycode(4)45 # ç¹å»çº¦çå表第ä¸ä¸ª 并ç³è¯·å å
¥46 def test_join(self):47 list_view=self.driver.find_element_by_id("com.example.lenovo.enjoyball:id/lv_time_demand")48 list_items = list_view.find_elements_by_class_name("android.widget.LinearLayout")49 list_items[0].click()50 self.driver.find_element_by_xpath("//*[@text='èä½ä»¥å¾
']").click()51 self.driver.find_element_by_id("android:id/button1").click()52 assert "请ä¸è¦éå¤æ交ç³è¯·" in \53 self.driver.find_element_by_xpath("//*[@class='android.widget.Toast']").text54 self.driver.press_keycode(4)55 #ç¹å»æççé¢è¿å
¥çº¦ç56 def test_yueqiu(self):57 self.driver.find_element_by_id("iv_main_portrait").click()58 time.sleep(3)59 self.driver.find_element_by_id("ll_personalcenter_yueqiu").click()60 self.driver.press_keycode(4)61 self.driver.press_keycode(4)62 # ç¹å»èªå·±å建çéä¼å¹¶ç³è¯·å å
¥63 def test_join_my(self):64 self.driver.find_element_by_id("img_main_time").click()65 self.driver.find_element_by_id("tv_main_tabletennis").click()66 list_view=self.driver.find_element_by_id("com.example.lenovo.enjoyball:id/lv_time_demand")67 list_items = list_view.find_elements_by_class_name("android.widget.LinearLayout")68 list_items[0].click()69 self.driver.find_element_by_xpath("//*[@text='èä½ä»¥å¾
']").click()70 assert "ä¸è½å å
¥èªå·±çéä¼" in \71 self.driver.find_element_by_xpath("//*[@class='android.widget.Toast']").text72 self.driver.press_keycode(4)73 time.sleep(3)74 # æ·»å å½åæ¶é´ç约ç75 def test_add_data(self):76 self.driver.find_element_by_id("img_main_time").click()77 self.driver.find_element_by_id("fab_demand_add").click()78 self.driver.find_element_by_id("sp_createagreement_type").click()79 self.driver.find_element_by_xpath("//*[@text='足ç']").click()80 self.driver.find_element_by_id("tv_getData").click()81 # æ¥æ82 list_view = self.driver.find_element_by_id("android:id/pickers")83 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")84 list_items[1].find_element_by_class_name("android.widget.Button").click()85 self.driver.find_element_by_xpath("//*[@text='5']").click()86 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()87 # æ¶é´88 self.driver.find_element_by_id("tv_getTime").click()89 list_view = self.driver.find_element_by_id("android:id/timePickerLayout")90 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")91 list_items[1].find_element_by_class_name("android.widget.Button").click()92 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()93 self.driver.find_element_by_id("btn_createagreement_OK").click()94 self.driver.find_element_by_id("android:id/button1").click()95 assert "约çéä¼å建æå" in \96 self.driver.find_element_by_xpath("/hierarchy/android.widget.Toast").text97 self.driver.press_keycode(4)98 # æ·»å å½åæ¶é´ä¹åç约ç99 def test_add_before(self):100 self.driver.find_element_by_id("img_main_time").click()101 self.driver.find_element_by_id("fab_demand_add").click()102 self.driver.find_element_by_id("sp_createagreement_type").click()103 self.driver.find_element_by_xpath("//*[@text='足ç']").click()104 self.driver.find_element_by_id("tv_getData").click()105 # æ¥æ106 list_view = self.driver.find_element_by_id("android:id/pickers")107 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")108 list_items[1].find_element_by_class_name("android.widget.Button").click()109 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()110 # æ¶é´111 self.driver.find_element_by_id("tv_getTime").click()112 list_view = self.driver.find_element_by_id("android:id/timePickerLayout")113 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")114 list_items[1].find_element_by_class_name("android.widget.Button").click()115 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()116 self.driver.find_element_by_id("btn_createagreement_OK").click()117 self.driver.find_element_by_id("android:id/button1").click()118 assert "约çéä¼å建æå" in \119 self.driver.find_element_by_xpath("/hierarchy/android.widget.Toast").text120 self.driver.press_keycode(4)121 # æ·»å å½åæ¶é´ä¹åç约ç122 def test_add_after(self):123 self.driver.find_element_by_id("img_main_time").click()124 self.driver.find_element_by_id("fab_demand_add").click()125 self.driver.find_element_by_id("sp_createagreement_type").click()126 self.driver.find_element_by_xpath("//*[@text='足ç']").click()127 self.driver.find_element_by_id("tv_getData").click()128 # æ¥æ129 self.driver.find_element_by_xpath("//*[@text='6']").click()130 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()131 # æ¶é´132 self.driver.find_element_by_id("tv_getTime").click()133 list_view = self.driver.find_element_by_id("android:id/timePickerLayout")134 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")135 list_items[1].find_element_by_class_name("android.widget.Button").click()136 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()137 self.driver.find_element_by_id("btn_createagreement_OK").click()138 self.driver.find_element_by_id("android:id/button1").click()139 assert "约çéä¼å建æå" in \140 self.driver.find_element_by_xpath("/hierarchy/android.widget.Toast").text141 self.driver.press_keycode(4)142 # æ·»å å½åæ¶é´ 红é¦ç约ç143 def test_add_place(self):144 self.driver.find_element_by_id("img_main_time").click()145 self.driver.find_element_by_id("fab_demand_add").click()146 self.driver.find_element_by_id("sp_createagreement_type").click()147 self.driver.find_element_by_xpath("//*[@text='æç']").click()148 self.driver.find_element_by_id("tv_getData").click()149 # æ¥æ150 list_view = self.driver.find_element_by_id("android:id/pickers")151 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")152 list_items[1].find_element_by_class_name("android.widget.Button").click()153 self.driver.find_element_by_xpath("//*[@text='5']").click()154 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()155 # æ¶é´156 self.driver.find_element_by_id("tv_getTime").click()157 list_view = self.driver.find_element_by_id("android:id/timePickerLayout")158 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")159 list_items[1].find_element_by_class_name("android.widget.Button").click()160 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()161 # å°ç¹162 self.driver.find_element_by_id("sp_createagreement_address").click()163 self.driver.find_element_by_xpath("//*[@text='红é¦']").click()164 self.driver.find_element_by_id("btn_createagreement_OK").click()165 self.driver.find_element_by_id("android:id/button1").click()166 assert "约çéä¼å建æå" in \167 self.driver.find_element_by_xpath("/hierarchy/android.widget.Toast").text168 self.driver.press_keycode(4)169 # æ·»å å½åæ¶é´ 人æ°ä¸º4ç约ç170 def test_add_number(self):171 self.driver.find_element_by_id("img_main_time").click()172 self.driver.find_element_by_id("fab_demand_add").click()173 self.driver.find_element_by_id("sp_createagreement_type").click()174 self.driver.find_element_by_xpath("//*[@text='æç']").click()175 self.driver.find_element_by_id("tv_getData").click()176 # æ¥æ177 list_view = self.driver.find_element_by_id("android:id/pickers")178 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")179 list_items[1].find_element_by_class_name("android.widget.Button").click()180 self.driver.find_element_by_xpath("//*[@text='5']").click()181 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()182 # æ¶é´183 self.driver.find_element_by_id("tv_getTime").click()184 list_view = self.driver.find_element_by_id("android:id/timePickerLayout")185 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")186 list_items[1].find_element_by_class_name("android.widget.Button").click()187 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()188 # å°ç¹189 self.driver.find_element_by_id("sp_createagreement_address").click()190 self.driver.find_element_by_xpath("//*[@text='ç½é¦']").click()191 # 人æ°192 self.driver.find_element_by_id("sp_createagreement_num").click()193 self.driver.find_element_by_xpath("//*[@text='4']").click()194 self.driver.find_element_by_id("btn_createagreement_OK").click()195 self.driver.find_element_by_id("android:id/button1").click()196 assert "约çéä¼å建æå" in \197 self.driver.find_element_by_xpath("/hierarchy/android.widget.Toast").text198 self.driver.press_keycode(4)199 # æ·»å å½åæ¶é´ 人æ°ä¸º4 æ·»å ææ³è¯´ç约ç200 def test_add_say(self):201 self.driver.find_element_by_id("img_main_time").click()202 self.driver.find_element_by_id("fab_demand_add").click()203 self.driver.find_element_by_id("sp_createagreement_type").click()204 self.driver.find_element_by_xpath("//*[@text='æç']").click()205 self.driver.find_element_by_id("tv_getData").click()206 # æ¥æ207 list_view = self.driver.find_element_by_id("android:id/pickers")208 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")209 list_items[1].find_element_by_class_name("android.widget.Button").click()210 self.driver.find_element_by_xpath("//*[@text='5']").click()211 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()212 # æ¶é´213 self.driver.find_element_by_id("tv_getTime").click()214 list_view = self.driver.find_element_by_id("android:id/timePickerLayout")215 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")216 list_items[1].find_element_by_class_name("android.widget.Button").click()217 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()218 # å°ç¹219 self.driver.find_element_by_id("sp_createagreement_address").click()220 self.driver.find_element_by_xpath("//*[@text='ç½é¦']").click()221 # 人æ°222 self.driver.find_element_by_id("sp_createagreement_num").click()223 self.driver.find_element_by_xpath("//*[@text='4']").click()224 # ææ³è¯´225 self.driver.find_element_by_id("et_createagreement_say").click()226 self.driver.find_element_by_id("et_createagreement_say").send_keys("å æ²¹")227 self.driver.press_keycode(4)228 self.driver.find_element_by_id("btn_createagreement_OK").click()229 self.driver.find_element_by_id("android:id/button1").click()230 assert "约çéä¼å建æå" in \231 self.driver.find_element_by_xpath("/hierarchy/android.widget.Toast").text232 self.driver.press_keycode(4)233 # æ·»å å½åæ¶é´ é请人å å
¥ç约ç234 def test_add_invite1(self):235 self.driver.find_element_by_id("img_main_time").click()236 self.driver.find_element_by_id("fab_demand_add").click()237 self.driver.find_element_by_id("sp_createagreement_type").click()238 self.driver.find_element_by_xpath("//*[@text='æç']").click()239 self.driver.find_element_by_id("tv_getData").click()240 # æ¥æ241 list_view = self.driver.find_element_by_id("android:id/pickers")242 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")243 list_items[1].find_element_by_class_name("android.widget.Button").click()244 self.driver.find_element_by_xpath("//*[@text='5']").click()245 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()246 # æ¶é´247 self.driver.find_element_by_id("tv_getTime").click()248 list_view = self.driver.find_element_by_id("android:id/timePickerLayout")249 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")250 list_items[1].find_element_by_class_name("android.widget.Button").click()251 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()252 # é请253 self.driver.find_element_by_id("btn_createagreement_invite").click()254 self.driver.find_element_by_id("et_invite_search").click()255 self.driver.find_element_by_id("et_invite_search").send_keys("15833552353")256 self.driver.find_element_by_id("tv_invite_search").click()257 self.driver.find_element_by_id("tv_searchresult_invite").click()258 self.driver.find_element_by_id("android:id/button1").click()259 self.driver.press_keycode(4)260 time.sleep(3)261 self.driver.press_keycode(4)262 self.driver.press_keycode(4)263 self.driver.find_element_by_id("btn_createagreement_OK").click()264 self.driver.find_element_by_id("android:id/button1").click()265 assert "ä½ æ¶å°äºä¸ä¸ªæ°ç约çé请" in \266 self.driver.find_element_by_xpath("/hierarchy/android.widget.Toast").text267 self.driver.press_keycode(4)268 # æ·»å å½åæ¶é´ é请人å å
¥ç约ç269 def test_add_invite2(self):270 self.driver.find_element_by_id("img_main_time").click()271 self.driver.find_element_by_id("fab_demand_add").click()272 self.driver.find_element_by_id("sp_createagreement_type").click()273 self.driver.find_element_by_xpath("//*[@text='æç']").click()274 self.driver.find_element_by_id("tv_getData").click()275 # æ¥æ276 list_view = self.driver.find_element_by_id("android:id/pickers")277 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")278 list_items[1].find_element_by_class_name("android.widget.Button").click()279 self.driver.find_element_by_xpath("//*[@text='5']").click()280 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()281 # æ¶é´282 self.driver.find_element_by_id("tv_getTime").click()283 list_view = self.driver.find_element_by_id("android:id/timePickerLayout")284 list_items = list_view.find_elements_by_class_name("android.widget.NumberPicker")285 list_items[1].find_element_by_class_name("android.widget.Button").click()286 self.driver.find_element_by_id("btn_bottomsheetdialog_OK").click()287 # é请288 self.driver.find_element_by_id("btn_createagreement_invite").click()289 self.driver.find_element_by_id("et_invite_search").click()290 self.driver.find_element_by_id("et_invite_search").send_keys("158335523")291 self.driver.find_element_by_id("tv_invite_search").click()292 self.driver.press_keycode(4)293 self.driver.press_keycode(4)294 self.driver.find_element_by_id("btn_createagreement_OK").click()295 self.driver.find_element_by_id("android:id/button1").click()296 assert "约çéä¼å建æå" in \297 self.driver.find_element_by_xpath("/hierarchy/android.widget.Toast").text298 self.driver.press_keycode(4)299if __name__ == '__main__':...
test_tche_flutter.py
Source:test_tche_flutter.py
...41 print(els4[i].text)42 els4[i].click() 43 break 44 self.driver.is_keyboard_shown()45 self.driver.press_keycode(19); #Up46 self.driver.press_keycode(109); #Up47 self.driver.press_keycode(28); #del backspace48 self.driver.press_keycode(67); #del backspace 49 self.driver.press_keycode(28); #del backspace 50 self.driver.press_keycode(115); #Up51 self.driver.press_keycode(48); #T52 self.driver.press_keycode(31); #C53 self.driver.press_keycode(36); #H54 self.driver.press_keycode(33); #E55 self.driver.press_keycode(40); #L56 self.driver.press_keycode(37); #I 57 self.driver.press_keycode(42); #N58 self.driver.press_keycode(49); #u59 self.driver.press_keycode(52); #X60 self.driver.hide_keyboard()61 els4 = self.driver.find_elements_by_android_uiautomator('new UiSelector().className("android.widget.Button")')62 for i in range(len(els4)): 63 if ('Aplicar' in els4[i].text):64 els4[i].click()65 break 66 sleep(2)67 68 def test_finds(self):69 sleep(2)70 els = self.driver.find_elements_by_android_uiautomator("new UiSelector().enabled(true)") 71 for i in range(len(els)):72 print("ELS ENABLED",i,els[i].text) 73 els2 = self.driver.find_elements_by_android_uiautomator("new UiSelector().clickable(true)") 74 for i in range(len(els2)):75 print("ELS 2 CLICKABLED",i,els2[i].text)76 77 def test_input(self): 78 sleep(3) 79 els3 = self.driver.find_elements_by_android_uiautomator('new UiSelector().className("android.widget.Button")')80 for i in range(len(els3)): 81 if ('Limpar' in els3[i].text):82 els3[i].click()83 break84 sleep(2)85 els4 = self.driver.find_elements_by_android_uiautomator('new UiSelector().className("android.widget.EditText")')86 for i in range(len(els4)): 87 if ('App' in els4[i].text):88 print(els4[i].text)89 els4[i].click() 90 break 91 self.driver.is_keyboard_shown()92 self.driver.press_keycode(19); #Up93 self.driver.press_keycode(109);94 self.driver.press_keycode(28); 95 self.driver.press_keycode(67); 96 self.driver.press_keycode(28); #del backspace 97 self.driver.press_keycode(115);98 self.driver.press_keycode(48); #T99 self.driver.press_keycode(31); #C100 self.driver.press_keycode(36); #H101 self.driver.press_keycode(33); #E102 self.driver.press_keycode(40); #L103 self.driver.press_keycode(37); #I 104 self.driver.press_keycode(42); #N105 self.driver.press_keycode(49); #U106 self.driver.press_keycode(52); #X107 self.driver.press_keycode(62); #space108 self.driver.press_keycode(29); #A109 self.driver.press_keycode(40); #L110 self.driver.press_keycode(33); #E111 self.driver.press_keycode(35); #G112 self.driver.press_keycode(46); #R113 self.driver.press_keycode(33); #E114 self.driver.press_keycode(48); #T115 self.driver.press_keycode(33); #E116 self.driver.press_keycode(62); #117 self.driver.press_keycode(62); #118 self.driver.press_keycode(62); #119 self.driver.press_keycode(62); #120 self.driver.press_keycode(62); #121 self.driver.hide_keyboard()122 els4 = self.driver.find_elements_by_android_uiautomator('new UiSelector().className("android.widget.Button")')123 for i in range(len(els4)): 124 if ('Aplicar' in els4[i].text):125 els4[i].click()126 break127 128if __name__ == '__main__':129 suite = unittest.TestLoader().loadTestsFromTestCase(SimpleAndroidTests)...
test_key_event.py
Source:test_key_event.py
...7 cls = KeyEvent()8 press_keycode = MagicMock()9 cls.press_keycode = MagicMock()10 cls.press_keycode.return_value = True11 result = cls.press_keycode("menu")12 print(result)13 assert result == True14def test_press_back():15 cls = KeyEvent()16 press_keycode = MagicMock()17 cls.press_keycode = MagicMock()18 cls.press_keycode.return_value = True19 result = cls.press_keycode("back")20 print(result)21 assert result == True22def test_press_left():23 cls = KeyEvent()24 press_keycode = MagicMock()25 cls.press_keycode = MagicMock()26 cls.press_keycode.return_value = True27 result = cls.press_keycode("left")28 print(result)29 assert result == True30def test_press_right():31 cls = KeyEvent()32 press_keycode = MagicMock()33 cls.press_keycode = MagicMock()34 cls.press_keycode.return_value = True35 result = cls.press_keycode("right")36 print(result)37 assert result == True38def test_press_up():39 cls = KeyEvent()40 press_keycode = MagicMock()41 cls.press_keycode = MagicMock()42 cls.press_keycode.return_value = True43 result = cls.press_keycode("up")44 print(result)45 assert result == True46def test_press_down():47 cls = KeyEvent()48 press_keycode = MagicMock()49 cls.press_keycode = MagicMock()50 cls.press_keycode.return_value = True51 result = cls.press_keycode("down")52 print(result)53 assert result == True54def test_press_center():55 cls = KeyEvent()56 press_keycode = MagicMock()57 cls.press_keycode = MagicMock()58 cls.press_keycode.return_value = True59 result = cls.press_keycode("center")60 print(result)61 assert result == True62def test_press_search():63 cls = KeyEvent()64 press_keycode = MagicMock()65 cls.press_keycode = MagicMock()66 cls.press_keycode.return_value = True67 result = cls.press_keycode("search")68 print(result)69 assert result == True70def test_press_home():71 cls = KeyEvent()72 press_keycode = MagicMock()73 cls.press_keycode = MagicMock()74 cls.press_keycode.return_value = True75 result = cls.press_keycode("home")76 print(result)77def test_press_volume_up():78 cls = KeyEvent()79 press_keycode = MagicMock()80 cls.press_keycode = MagicMock()81 cls.press_keycode.return_value = True82 result = cls.press_keycode("volume_up")83 print(result)84 assert result == True85def test_press_volume_down():86 cls = KeyEvent()87 press_keycode = MagicMock()88 cls.press_keycode = MagicMock()89 cls.press_keycode.return_value = True90 result = cls.press_keycode("volume_down")91 print(result)92 assert result == True93def test_press_camera():94 cls = KeyEvent()95 press_keycode = MagicMock()96 cls.press_keycode = MagicMock()97 cls.press_keycode.return_value = True98 result = cls.press_keycode("camera")99 print(result)100 assert result == True101def test_press():102 cls = KeyEvent()103 press_keycode = MagicMock()104 cls.press_keycode = MagicMock()105 cls.press_keycode.return_value = True106 result = cls.press_keycode(0x07, 0x02)107 print(result)108 assert result == True109def test_press_with_device():110 cls = KeyEvent()111 press_keycode = MagicMock()112 cls.press_keycode = MagicMock()113 cls.press_keycode.return_value = True...
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!!