This tutorial shows how to automate multiple devices on the same network by using the askui library. After following this tutorial, you will be able to automate more than one device at the same time across different platforms, whether Linux, macOS, Windows, or Android, with a single setup with the askui library.
In fact, there are many automation tools in the wild which you can use to automate different devices, although most of them require different configurations and different test code for different platforms. By using the askui library, an automation tool that operates on the OS level, you can simply use the same test code for any application running on different devices even without so much change. And this makes the askui a powerful Cross-platform automation tool.
Let's have a look at the askui library and see how we can accomplish a Cross-platform/-device automation test🔥
📌 The following tutorial assumes that you have already installed and set up the askui library on your local device. The code for the configuration is based on the generated test code: npx askui init. See Getting Started for more details.
1. Download and Prepare the askui-ui-controller Binary for Each Device
- If you already used the askui library once, then the binary for your platform already exists in the node_modules/ directory, as the binary gets automatically downloaded if an instance of UiController gets initialized. See here for more details about the askui UI Controller.
- Follow this path and confirm that the binary exists:
- If the remote device runs the same platform as the local device, simply copy the binary from the local device to the remote device.
- If the remote device runs a different platform, then download the binary for the respective platform: Windows | macOS(intel) | macOS(silicon) | Linux
- There is no need to save the binary to Android devices. They are controlled by the askui UI Controller running on the local device (desktop).
- Be sure that your Android device is discoverable by the ADB from your local device:
- If you don't have the ADB installed on your local device, set it up by following this tutorial.
- Use the commands below, if you want to connect your Android device via ADB wirelessly:
2. Configure the jest.setup.ts
- Figure out the local ip address of the remote device with the following command:
- Change the IP address <local-ip-address> in the test/helper/jest.setup.ts:
3. Run the Controller on Each Device
- Run the binary askui UI Controller on the local and remote devices with the following command:
- If running successfully, you should see the logs printed on the terminal, e.g:
[2023-01-02 17:31:19.634 +0100] DEBUG (AskuiUiController): Window is minimized.
[2023-01-02 17:31:19.639 +0100] INFO (AskuiUiController): Selecting display number 0.
[2023-01-02 17:31:19.641 +0100] INFO (AskuiUiController): Successfully started.
- If your remote device is an Android device, run the askui UI Controller on the local device (desktop) with an extra option as below:
- Make sure that your local device (desktop) is running TWO DIFFERENT askui-ui-controller, if you want to control the local device and the Android device at the same time.
(option) Running Multiple Android Devices
- The askui UI Controller considers all the Android devices as a single device with multiple displays. To see the GUI of the display selection, set the minimize option(-m) to false from the commands below. The screenshot below shows what it looks like.
- Note that you have to create another instance of UiControlClient in the test/helper/jest.setup.ts with the respective ip:port that is given to the android device.
- Set the display number (-d option) of the binary differently for each Android device.
- Set the port number (-p option) of the binary differently for each Android device.
4. Write the Automation Code
- Write the test code in test/my-first-askui-test-suite.test.ts:
5. Run the Automation Code
- Run the command below to run the askui test code:
- Now you should be able to automate multiple devices in the network. If you got any issues while following this tutorial, don't hesitate to ask our Discord Community!
More to explore
Try askui in Your Browser With Gitpod
askui controls your operating system (OS) through mouse movement, mouseclicks, keypresses and screencapture.Thus it can be a pain to install it on your local machine. Not everything might work out of the box or there are simply permissions missing (looking at you macOS ).But we have a solution we will show you in this blog post!Our GitHub repository has a ready-to-go Gitpod configuration inside where you can try out askui for free in your browser without any installation issues.All you need is a GitHub account and a Gitpod account 🦄
How to Use Custom Elements in askui
Custom Element Selection is a feature in askui that enables you to create custom selectors for elements on the screen, instead of relying on the standard selectors provided such as Button, Textfield, etc. .Here we will demonstrate how to use a custom element to explore Google Street View.