The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach. |
An Android device may have a number of physical buttons: Power, Volume, Home, Recent, Dial, Camera, and so on. Depending on the device type and model, the set of available buttons may vary greatly: from a single Power button to a full-fledged QWERTY keyboard. Yet, the majority of Android devices have from one to six physical buttons.
This topic describes how you can simulate physical button events with TestComplete.
Note: | Depending on the device and on the activities running on it, the device may react to button pressing in a different manner or it may not react at all. |
Simulating Actions Over Physical Buttons
With TestComplete, you can simulate actions over various physical buttons on your mobile device. It may be useful to:
-
Simulate button events on Android devices like netbooks, media players, set-top boxes and other devices having different sets of physical buttons.
-
Initiate specific actions or activities that are performed upon pressing certain physical buttons.
To simulate pressing any physical button, you can call the Device.PressButton
method. The parameters of the method specify the physical button to be emulated (for the full list of buttons available for emulation, see Mobile Key Constants) and the type of action to simulate (press button, release button or press and release button). Additionally, to simulate pressing the Back and Home buttons, you can use the Device.PressBack and Device.PressHome methods respectively.
Note: | These methods are asynchronous. This means that TestComplete does not pause the test when they are executed. For more information, see Possible Issues. |
Simulating Physical Button Events in Keyword Tests
Simulating Physical Button Events in Scripts
Recording Actions Over Physical Buttons
Currently, TestComplete cannot record pressing of physical buttons on the connected mobile device. To record a physical button event, you need to press one of the emulated buttons on the Mobile Screen window.
The buttons of the Mobile Screen footer represent the following most frequently used physical buttons: Back, Home, Recent, Volume Down, Volume Up and On/Off. TestComplete records pressing these buttons as calls to the Device.PressButton
method.
Note: | For pressing the Back and Home buttons, TestComplete records the calls to the Device.PressBack and Device.PressHome methods respectively. |
A mobile device may emulate physical buttons (Back, Home, Recent, etc.) on its touch screen, so the Mobile Screen window will contain two sets of emulated physical buttons: one set on the device’s screen and another set in the window footer.
We recommend that you use buttons on the Mobile Screen footer to record actions over the device’s physical buttons. Otherwise, pressing screen-rendered buttons is interpreted as on-screen actions and is recorded as calls to the Touch
method of the Device
object.
See Also
Simulating User Actions Over Android Devices (Legacy)
Mobile Key Constants
Recording Gestures (Multi-Touch Events) (Legacy)
Simulating Basic Touch Actions Over Android Devices (Legacy)
Simulating Text Input on Android Devices (Legacy)