Dry goods | Detailed Explanation of Device Interaction API for App Automation Testing

Appium provides a lot of system operations, and there will be some special scenarios in the process of testing the APP, such as incoming calls, text messages, switching between horizontal and vertical screens, installing/uninstalling APPs, keyboard operations on mobile phones, screen recording and other functions. The following introduces several commonly used device interaction APIs.
For more usage, see the official website:
http://appium.io/docs/en/about-appium/intro/

Analog Phone/SMS

Use the following commands to simulate GSM calls and text messages. Note: it can only be used on the simulator!

self.driver.make_gsm_call("5551234567", GsmCallActions.CALL);

self.driver.send_sms('555-123-4567', 'Hey lol')

App operation

# 实现 APP 的安装
self.driver.install_app('/Users/johndoe/path/to/app.apk') 

# 检测 APP 是否被安装
self.driver.is_app_installed('com.example.AppName');

# 启动 APP
self.driver.launch_app()

how to install weditor

For keyboard events, please refer to the Android official website:
https://developer.android.com/reference/android/view/KeyEvent.html
The following shows whether the button, long press, hidden keyboard, and soft keyboard are displayed. The code is as follows:

self.driver.press_keycode(10)
self.driver.long_press_keycode(10)
self.driver.hide_keyboard()
self.driver.is_keyboard_shown()

Set the contents of the system clipboard:

self.driver.set_clipboard('happy testing')
self.driver.set_clipboard_text('happy testing')

Get the contents of the clipboard:

self.driver.get_clipboard()
self.driver.get_clipboard_text()

The device interaction API will talk about these first, and finally share the software testing learning materials and routes summarized by myself, including testing theory, Linux foundation, MySQL foundation, Web testing, interface testing, App testing, Python foundation, Selenium related, performance testing, LordRunner related, etc. [Click on the small card at the end of the article to get it for free]

Resource acquisition method:

 

Guess you like

Origin blog.csdn.net/HUA1211/article/details/131667479