Automated Testing with Appium Inspector
Astrofarm provides a private pool of real Android and iOS devices that your team can access for UI inspection, element discovery, and automated test authoring using Appium Inspector. This guide covers how to connect Appium Inspector to the Astrofarm device cloud, configure your desired capabilities, and start an interactive inspection session on a real device.
What You’ll Need
- An Astrofarm account with access credentials
- Appium Inspector installed (v2024.x or later recommended)
- Access to your organisation’s Astrofarm Account
- A mobile app file (.apk / .aab for Android, .ipa for iOS) uploaded to Astrofarm App Storage
Appium Inspector connects to Astrofarm using the standard WebDriver protocol over HTTPS. Ensure your machine can reach the Astrofarm server URL - check with your infrastructure team if you are behind a firewall.
Step 1: Configure the Appium Inspector Server
Open Appium Inspector and navigate to the Server tab. Select Custom Server and enter the following Astrofarm connection details:
| Field | Value | Notes |
|---|---|---|
| Remote Host | appium.astrofarm.com | Replace with your actual Astrofarm hostname |
| Port | 443 | Default Appium port; confirm with your admin |
| Remote Path | /d/appium/your_Device unique_security_token_here | Standard Appium server path in the device |
| SSL | true (HTTPS) | Required for all Astrofarm connections |
Step 2: Set Desired Capabilities
Capabilities tell Astrofarm which device to allocate and how to configure the session. Switch to the Desired Capabilities tab in Appium Inspector and add the following entries.
Required Capabilities
| Capability | Type | Description |
|---|---|---|
platformName - required | String | Android or iOS |
appium:automationName - required | String | UiAutomator2 (Android) or XCUITest (iOS) |
appium:deviceName - required | String | The physical device slot address under the Appium Automation |
appium:uiautomator2Serv - required | Number | Extends timeout buffers to prevent drops over networks |
Example Capability JSON - Android (Pixel 7, Android 13)
JSON - Android
{
"appium:platformName": "Android",
"appium:deviceName": "Pixel 7.*",
"appium:platformVersion": "13",
"appium:automationName": "UiAutomator2",
"appium:app": "storage:filename=MyApp.apk",
"appium:noReset": false,
"astrofarm:apiKey": "YOUR_API_KEY_HERE",
"astrofarm:sessionName": "Inspector - Android Smoke"
}
Step 3: Start a Session
Follow these steps to launch an interactive inspection session:
Launch Appium Inspector. Open the Appium Inspector app on your machine. Ensure you are connected to the Astrofarm VPN if required.
Select Custom Server. On the start screen, choose the Custom Server option and fill in the Astrofarm host URL, port, and path as described in Step 1.
Enter Desired Capabilities. Switch to the Desired Capabilities tab and paste your JSON configuration, or enter key-value pairs manually. Include your astrofarm:apiKey.
Click Start Session. Appium Inspector contacts the Astrofarm server, allocates a matching device, installs your app, and opens an interactive session.
Inspect Elements. Use the UI tree panel to tap and inspect elements. Locators (accessibility ID, XPath, resource-id) appear in the right panel and can be copied directly into your test scripts.
Uploading Your App to Astrofarm
Your app must be available in Astrofarm App Storage before starting a session. Supported formats:
.apk / .aabAndroid app packages.ipaiOS app archives (must be signed)
Upload via REST API
- REST API - cURL
curl --location
'https://astrofarmurl.com/api/v2/appstore/add' \
--header 'Authorization: Bearer
--form 'appFile=@"/path/to/file"'
- REST API - Node.js
var request = require('request');
var fs = require('fs');
var options = {
‘method': 'POST',
‘url':
'https://astrofarmurl.com/api/v2/appstore/add',
‘headers': {
‘Authorization': 'Bearer YOUR_API_KEY'
},
formData: {
‘appFile': {
‘value':
fs.createReadStream('/path/to/file'),’
‘options': {
‘filename': 'astrocontacts.apk',
‘contentType': null
}
}
}
};
request(options, function (error, response)
{
if (error) throw new Error(error);
console.log(response.body);
});
- REST API - Java
OkHttpClient client = new
OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("appFile","astrocontacts.apk",
RequestBody.create(MediaType.parse("application/octet-stream"),
new File("/path/to/file")))
.build();
Request request = new Request.Builder()
.url("https://astrofarmurl.com/api/v2/appstore/add")
.method("POST", body)
.addHeader("Authorization", "Bearer YOUR_API_KEY")
.build();
Response response = client.newCall(request).execute();
Use the Device
This API attempts to add a device under the authenticated user's control which is equivalent to pressing Use in the Astrofarm UI.
- REST API - cURL
curl --location "https://astrofarmurl.com/api/v1/user/devices" --header "Content-Type: application/json" --header "Authorization: Bearer YOUR_API_KEY" --header "Cookie: __Host-user=admin" --data "{'serial': '4xxx2315dxxab4xx','timeout': 240}"
- REST API - Node.js
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://astrofarmurl.com/api/v1/user/devices',
'headers': {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY',
'Cookie': '__Host-user=admin'
},
body: JSON.stringify({
"serial": "4xxx2315dxxab4xx",
"timeout": 240
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
- REST API - Java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"serial\": \"4xxx2315dxxab4xx\",\n \"timeout\": 240\n}");
Request request = new Request.Builder()
.url("https://astrofarmurl.com/api/v1/user/devices")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer YOUR_API_KEY")
.addHeader("Cookie", "__Host-user=admin")
.build();
Response response = client.newCall(request).execute();