How to use press_keycode method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

test_enjoyball.py

Source:test_enjoyball.py Github

copy

Full Screen

...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__':...

Full Screen

Full Screen

test_tche_flutter.py

Source:test_tche_flutter.py Github

copy

Full Screen

...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)...

Full Screen

Full Screen

test_key_event.py

Source:test_key_event.py Github

copy

Full Screen

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

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