Emulators (Android devices)
Emulators simulate the hardware and software of Android devices on your computer. They are great for lightweight and early testing, when you need to get started and receive quick feedback. Emulators create an operating environment that looks and functions much like the mobile device model, providing almost all of the capabilities of a real Android device. This includes the simulation of incoming phone calls and text messages, location services, various network speeds, device orientation (rotation), and different hardware sensors.
Testing your app on emulators may be faster and easier than doing so on a physical device, for example because it is faster to transfer data to the emulator than to a device connected over USB. However, as your app matures and you proceed in the development and testing cycle, you will also want to test on real devices under real-world user conditions, with real gestures, and for the most accurate performance load results.
If you are already familiar with Perfecto and want to switch from a real device to an emulator, take a look at the supported capabilities.
If you are new to Perfecto, watch the video and see the detailed steps under 1 | Configure and run your test and 2 | View execution results.
On this page:
Supported Appium and Selenium versions for emulators
As a best practice, consider selecting only the version of the Appium client to use and letting the natural dependency and compatibility between Appium server and Selenium client versions take care of the rest. If you need to select a specific Selenium client, you must make sure that the client version is compatible with the selected version of the Appium client.
For virtual devices, Perfecto supports Appium server 1.17.1 or later and 2.2 or later. For details, see Supported platforms.
Supported emulator devices and OS versions
Perfecto supports emulators for Android versions 10 and later, as specified in the following table. By default, Perfecto selects Google Pixel 8 on Android 14.
The string in the Device model column corresponds to the value accepted by the deviceName
capability. The value is not case sensitive.
securedScreenInstrument
. To turn on instrumentation of secured screens, set this capability to true
. See also Install application (FR).Manufacturer | Device model | Android version |
---|---|---|
Samsung |
Galaxy S8 |
10, 11, 12 |
Samsung |
Galaxy S9 |
10, 11, 12 |
Samsung |
Galaxy S9 Plus |
10, 11, 12 |
Samsung |
Galaxy Note9 |
10, 11, 12 |
Samsung |
Galaxy S10 |
10, 11, 12 |
Samsung |
Galaxy S10e |
10, 11, 12 |
Samsung |
Galaxy S10 Plus |
10, 11, 12 |
Samsung |
Galaxy Note10 |
10, 11, 12 |
Samsung |
Galaxy Note10 Plus |
10, 11, 12 |
Samsung |
Galaxy S20 Ultra |
11, 12, 13 |
Samsung |
Galaxy S20 Plus |
11, 12, 13 |
Samsung |
Galaxy S20 |
11, 12, 13 |
Samsung |
Galaxy S21 |
11, 12, 13, 14 |
Samsung |
Galaxy S21 Plus |
11, 12, 13, 14 |
Samsung |
Galaxy S21 Ultra |
11, 12, 13, 14 |
Samsung |
Galaxy S22 |
11, 12, 13, 14 |
Samsung |
Galaxy S22 Plus |
11, 12, 13, 14 |
Samsung |
Galaxy S23 |
13, 14 |
Samsung |
Galaxy S23 Plus |
13, 14 |
Samsung |
Galaxy S23 Ultra |
13, 14 |
Samsung |
Galaxy S24 |
14 |
Samsung |
Galaxy S24 Plus |
14 |
Samsung |
Galaxy S24 Ultra |
14 |
Samsung |
Galaxy Z Fold 5 |
14 |
Samsung |
Galaxy Z Flip 5 |
14 |
|
Pixel 3 XL |
10, 11 |
|
Pixel 3 |
11 |
|
Pixel 3a XL |
11 |
|
Pixel XL |
11 |
|
Pixel 4 |
10, 11, 12, 13 |
|
Pixel 4 XL |
12, 13 |
|
Pixel 4a |
11, 12, 13 |
|
Pixel 4a 5g |
12, 13, 14 |
|
Pixel 5 |
12, 13, 14 |
|
Pixel 6 |
12, 13, 14, 15, 16 Developer Preview |
|
Pixel 6a |
14, 15 |
|
Pixel 6 Pro |
13, 14, 15 |
|
Pixel 7 |
13, 14, 15 |
|
Pixel 7a |
14, 15 |
|
Pixel 7 Pro |
13, 14, 15 |
|
Pixel 8 |
14, 15 |
|
Pixel 8 Pro |
14, 15 |
|
Pixel Fold |
14, 15 |
|
Pixel 9 |
14, 15 |
|
Pixel 9 Pro |
14, 15 |
|
Pixel 9 XL |
14, 15 |
Demo video
Watch the video to see how to work with emulators in Perfecto.
For your convenience, following is the script used in the video. You can run it in your environment with the following changes:
<your_token>
: The Perfecto security token for your user. For information about obtaining a token, see Generate security tokens.<your_cloud_URL>
: The URL for your Perfecto cloud.
Emulators sample script
package io.appium.java_client.ios;
import com.perfecto.reportium.client.ReportiumClient;
import com.perfecto.reportium.client.ReportiumClientFactory;
import com.perfecto.reportium.model.Job;
import com.perfecto.reportium.model.PerfectoExecutionContext;
import com.perfecto.reportium.model.Project;
import com.perfecto.reportium.test.TestContext;
import com.perfecto.reportium.test.result.TestResultFactory;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
public class EmulatorsWebDemoTest {
public static ReportiumClient reportiumClient;
protected static AndroidDriver<AndroidElement> driver;
String expectedPageTitle = "My Store";
private static By ADD_TO_CART = By.xpath("//*[@id=\"homefeatured\"]//*[@class=\"ajax_block_product col-xs-12 col-sm-4 col-md-3 first-in-line first-item-of-tablet-line first-item-of-mobile-line\"]/div[1]/div[2]/div[2]/a[1]/span[1]");
private static By CHECKOUT = By.xpath("//*[@class=\"btn btn-default button button-medium\"]");
private static By CART = By.xpath("//*[text()=\"Cart\"]");
private static By CHECK_OUT = By.xpath("//*[@id=\"button_order_cart\"]");
@BeforeClass
public static void beforeClass() throws UnknownHostException, MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
String host = "<your_cloud_URL>";
capabilities.setCapability("securityToken", "<your_token>");
capabilities.setCapability("deviceName", "Pixel 3");
capabilities.setCapability("useVirtualDevice", true);
capabilities.setCapability("automationName", "Appium");
capabilities.setCapability("browserName", "Chrome");
driver = new Android(new URL("https://" + host + "/nexperience/perfectomobile/wd/hub"), capabilities);
PerfectoExecutionContext perfectoExecutionContext = new PerfectoExecutionContext.PerfectoExecutionContextBuilder()
.withProject(new Project("Emulators", "1.0"))
.withJob(new Job("Android tests emulators", 45).withBranch("branch-name"))
.withContextTags("Sanity")
.withWebDriver(driver)
.build();
reportiumClient = new ReportiumClientFactory().createPerfectoReportiumClient(perfectoExecutionContext);
}
@Test
public void EmulatorWebDemoTest() throws InterruptedException {
reportiumClient.testStart("Android Web 'Demo' test", new TestContext("androidWeb"));
System.out.println("************** START TEST *********************");
reportiumClient.stepStart("Open 'http://automationpractice.com/' url");
driver.get("http://automationpractice.com/");
reportiumClient.stepEnd();
Thread.sleep(2000);
reportiumClient.stepStart("Get url Title");
String actualPageTitle = driver.getTitle();
System.out.println("Page Title: " + actualPageTitle);
Assert.assertEquals(expectedPageTitle, actualPageTitle);
reportiumClient.stepEnd();
reportiumClient.stepStart("Clicking on 'Add to cart' button");
System.out.println("Clicking on 'Add to cart' button");
driver.findElement(ADD_TO_CART).click();
reportiumClient.stepEnd();
reportiumClient.stepStart("Get Screenshot");
System.out.println("Get Screenshot");
driver.getScreenshotAs(OutputType.BYTES);
reportiumClient.stepEnd();
Thread.sleep(2000);
reportiumClient.stepStart("Clicking on 'Proceed to checkout' button");
System.out.println("Clicking on 'Proceed to checkout' button");
driver.findElement(CHECKOUT).click();
reportiumClient.stepEnd();
Thread.sleep(2000);
reportiumClient.stepStart("Clicking on 'Cart' button");
System.out.println("Clicking on 'Cart' button");
driver.findElement(CART).click();
reportiumClient.stepEnd();
Thread.sleep(2000);
reportiumClient.stepStart("Clicking on 'Check Out' button");
System.out.println("Clicking on 'Check Out' button");
driver.findElement(CHECK_OUT).click();
reportiumClient.stepEnd();
System.out.println("************** END TEST *********************");
reportiumClient.testStop(TestResultFactory.createSuccess());
}
@AfterClass
public static void afterClass () {
String reportURL = reportiumClient.getReportUrl();
System.out.println("Report URL - " + reportURL);
if (driver != null) {
driver.quit();
}
}
}
1 | Configure and run your tests
This step walks you through adding the required capabilities to your existing Appium test scripts against a virtual mobile device. For comprehensive information on how to make Appium test scripts work with Perfecto, including adding dependencies and integrating with Perfecto Smart Reporting, see Appium.
When working with Appium 2, which requires Java client 8.1.x, you must add the prefix perfecto:
to any non-Appium capability (for example: “perfecto:useVirtualDevice”, true
) or use the perfectoOptions
notation. For details on upgrading to an Appium 2-complient client, see Upgrade to an Appium 2-compliant client and Appium 2-compliant client and Selenium 4 sample project.
For more information on capabilities, see Supported capabilities for virtual mobile devices.
To configure and run your tests:
-
Open an existing test script in the IDE of your choice.
The following sample code snippet is not yet configured to run in Perfecto. It opens an app (Safari) on a mobile platform (iOS) of a specific version (13.3). The device name is specific (iPhone X).CopyPure Appium script not running on Perfectopublic static void main(String[] args) throws MalformedURLException, IOException {
System.out.println("Run started");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("deviceName", "Pixel 4");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "11");
AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub/"), capabilities);
driver.quit();
System.out.println("Run ended");
} -
Configure the script to run in Perfecto by following the steps in the Appium section. In particular, you need to add dependencies, provide the security token and URL required to connect to the Perfecto cloud, and create an instance of the reporting client to integrate with Perfecto Smart Reporting.
-
To run the test on a virtual device, add the capability
useVirtualDevice
and set it totrue
. The script should now look similar to the following. For more information on the individual capabilities, see Supported capabilities for virtual mobile devices and Supported Appium capabilities.To install the application to be tested on the simulator, use the
app
capability. The application specified by this capability is installed and launched automatically at the beginning of the script. If you need to install more than one app, use theapp
capability for the main application and theotherApps
capability for additional apps. For more information, see Supported Appium capabilities and the Appium information on General Capabilities.CopyAppium script running on Perfecto against a virtual devicepublic static void main(String[] args) throws MalformedURLException, IOException {
System.out.println("Run started");
String cloudName = System.getProperty("cloudName");//Line added
String securityToken = System.getProperty("securityToken");//Line added
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("deviceName", "Pixel 4");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "11");
capabilities.setCapability("securityToken", securityToken);//Line added
capabilities.setCapability("useVirtualDevice", true);//Line added
AndroidDriver driver = new AndroidDriver(new URL("https://" + cloudName + "/nexperience/perfectomobile/wd/hub"), capabilities);//Line modified
driver.quit();
System.out.println("Run ended");
} -
If you want to run your test on an emulator other than GoogleAPI, add the capability
emulatorType
and set it toAndroid
orPlaystore
.Playstore provides more options and capabilities, but it it slower than the default emulator. Android provides less functions than the default but is slightly faster.
- Save your test.
- To avoid script failure, check if a simulator license is available via the Get License Information by Type API.
- If a license is available, run your script.
2 | View execution results
To view execution results:
- When your test execution has finished, go to your Perfecto cloud instance and click Analyze Reports to open the Test Analysis view.
In the Report Library, in the right pane, under Filter, select Platform type > Virtual devices.
If the right pane is not visible, click Configure View to open it.
The report list refreshes to show only tests run on a simulator, as indicated by the simulator icon in the Platform column.
For more information on filtering, see Focus on what's important to you.- Click the relevant test report.
- In the test view, do any of the following:
- In the left pane, under Test Flow, review the test steps.
- In the right pane, play the video.
- At the top right, click the download button to download the full report or the video.