Illustration of testing on simulators and emulators
May 10, 2021

How to Test on Simulators & Emulators With Perfecto

Mobile Application Testing

Virtual devices can help teams shift left and catch bugs earlier, faster, and resolve them more easily during mobile testing. By combining virtual and real devices, organizations benefit from a more robust mobile testing strategy, enabling comprehensive application quality at a much lower cost. 

In this article, we will show you how to test on Perfecto emulators and simulators using Appium scripts. Perfecto has long supported open-source frameworks like Selenium and Appium. The integration supports 100% Appium code, while also offering multiple benefits to run tests in the same way as your end users.  

Back to top

Perfecto Simulators & Emulators 

What do emulators and simulators look like in Perfecto? Below you will find a view of our Samsung Galaxy S9 Emulator and Apple iPhone 12 Pro Max Simulator on the Perfecto UI. These are just two examples of many virtual devices that are available in Perfecto’s device lab.  

Perfecto mobile testing on virtual devices
Back to top

Getting Started With Virtual Devices 

To work with virtual devices on Perfecto, you only need to add one capability to the code. (Note:  “DeviceName” capability is not available for virtual devices. If your code relies on DeviceName, then you need to refactor your code to add the above capabilities, in order to run the same Appium script on virtual devices.) 

Setting Base Desired Capabilities for Android (Emulator) 

For example, see this Base Desired Capabilities for a Samsung S9 virtual device. 

DesiredCapabilities capabilities = new DesiredCapabilities("", "", Platform.ANY); 
capabilities.setCapability("platformName", "Android"); 
capabilities.setCapability("platformVersion", "9"); 
capabilities.setCapability("manufacturer", "Samsung"); 
capabilities.setCapability("model", "galaxy s9"); 
capabilities.setCapability("useVirtualDevice", true); 

The last line of code says that the device the user needs is a virtual device. Since the platform is an Android, this virtual device will be an emulator. 

Setting Base Desired Capabilities for iPhone (Simulator) 

Now, let us look at the Base Desired Capabilities for an Apple iPhone Xs device.

DesiredCapabilities capabilities = new DesiredCapabilities("", "", Platform.ANY); 
capabilities.setCapability("platformName", "iOS"); 
capabilities.setCapability("platformVersion", "14.2"); 
capabilities.setCapability("manufacturer", "Apple"); 
capabilities.setCapability("model", "iPhone Xs"); 
capabilities.setCapability("useVirtualDevice", true); 

To automate tests for a web application, we need to add the browserName capability. This would be “Chrome” for emulators and “Safari” for simulators. 

  //For Emulators 
  //For Simulators 
 capabilities.setCapability("browserName”, Safari"); 

Executing a Parallel Test With Virtual Devices for a Web App  

In the video below, you will see how quickly you can execute a parallel test on Perfecto virtual devices for a web application. 

To automate tests for a native application, provide the following paths after you set Base Desired Capabilities: 

  • Android: .Apk path and AppPackage  
  • iOS: .App path and Bundled – iOS Simulators support only .app, unlike .ipa for real devices 
  //For Emulators 
  //For Simulators 
Back to top

Executing a Parallel Test on a Virtual Device for a Native Mobile App 

See how a test execution happens on Perfecto virtual devices for a native application. 

Code Sample  

Code sample of parallel testing on a Perfecto virtual device
Back to top

Bottom Line 

As you can see, getting set up with virtual devices does not take long. The executions go quickly too! Testing on simulators and emulators is simpler than ever with Perfecto. Pairing these virtual devices with real devices allows organizations to test faster and get the coverage they need. 

Watch Simulators and Emulators in Action 

See a demo of virtual devices with Perfecto. 

Get Demo

Back to top