How to use test_keyevent method in Airtest

Best Python code snippet using Airtest

11_keyevent.py

Source:11_keyevent.py Github

copy

Full Screen

...12 desired_caps['appActivity'] = '.ui.base.SplashActivity'13 self.driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)14 def tearDown(self) -> None:15 self.driver.quit()16 def test_keyevent(self):17 """Android keycode安卓的一些按键"""18 """常用的几个按键:19 KEYCODE_MENU 菜单键8220 KEYCODE_BACK 返回键421 KEYCODE_SEARCH 搜索键8422 KEYCODE_ENTER 回车键6623 KEYCODE_DEL 退格键6724 后续需要用其他按键可以在百度搜索Android keycode"""25 self.driver.implicitly_wait(60)26 # 定位搜索按钮27 ele = self.driver.find_element_by_id("cn.xiaochuankeji.tieba:id/ic_search_b")28 ele.click() # 点击它29 # 安卓按键的使用方法,直接传对应按键的数值到keyevent()里面即可30 # 定位搜索输入框,并输入 Ailian...

Full Screen

Full Screen

test_events.py

Source:test_events.py Github

copy

Full Screen

...8 e = events.InputEvent(1036996631, 984417, ecodes.EV_REL, 0, 0)9 assert isinstance(util.categorize(e), events.RelEvent)10 e = events.InputEvent(1036996631, 984417, ecodes.EV_MSC, 0, 0)11 assert e == util.categorize(e)12def test_keyevent():13 e = events.InputEvent(1036996631, 984417, ecodes.EV_KEY, ecodes.KEY_A, 2)14 k = events.KeyEvent(e)15 assert k.keystate == events.KeyEvent.key_hold16 assert k.event == e17 assert k.scancode == ecodes.KEY_A...

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