Simulators (iPhones and iPads)

Simulators simulate iPhones and iPads on a Mac host. They are great for lightweight and early testing, when you need to get started and receive quick feedback. They create an operating environment that looks and functions like the mobile device model, but with limitations. Memory management, network management, and file management are all inherited from the host OS, and some simulators do not expose all of the functionality available in the target device, such as the camera or hardware sensors. In addition, simulators leverage the system resources from the host Mac OS, so it is not possible to obtain real performance data from tests.

Therefore, before testing on simulators, be aware that simulators are designed for basic functional testing. They cannot test:

  • Hardware components
  • Real-world user conditions
  • Gestures

Testing on simulators requires an .app file (not an .ipa file). This is a restriction imposed by Apple. Simulators cannot run .ipa files. Those files require real devices. For more information on creating a simulator build that is compatible with all iOS model simulators, see Create an iOS simulator buildTo receive the .app file, check with your development or engineering department.

Note

To upload an .app file to the Perfecto repository, you need to compress it into a .zip file. On Windows, .app files appear as folders, so you need to create the .zip file at the level of the .app folder.

For more information on running your app in the simulator, see this Apple article.

If you are already familiar with Perfecto and want to switch from a real device to a simulator, 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.

Supported Appium and Selenium versions

As a best practice, we recommend that you select only the version of the Appium client to use and let 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. For details, see Supported platforms.

Supported devices and OS versions

Perfecto supports simulators for iOS versions 12.x and later, as specified in the following table. By default, Perfecto selects iPhone 12 with iOS 14.4.

Note

The string in the Device model column corresponds to the value accepted by the deviceName capability. The value is not case sensitive.

Device

iOS version

iPad (5th generation)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad (6th generation)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad (7th generation)

13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad (8th generation)

14.0, 14.1, 14.2, 14.3, 14.4

iPad Air (3rd generation)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad Air (4th generation)

14.0, 14.1, 14.2, 14.3, 14.4

iPad Air 2

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad Pro (10.5-inch)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad Pro (11-inch) (1st generation)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad Pro (11-inch) (2nd generation)

13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad Pro (12.9-inch) (1st generation)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad Pro (12.9-inch) (2nd generation)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad Pro (12.9-inch) (3rd generation)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad Pro (12.9-inch) (4th generation)

13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad Pro (9.7-inch)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad mini (5th generation)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPad mini 4

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone 11

13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone 11 Pro

13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone 11 Pro Max

13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone 12

14.1, 14.2, 14.3, 14.4

iPhone 12 Pro

14.1, 14.2, 14.3, 14.4

iPhone 12 Pro Max

14.1, 14.2, 14.3, 14.4

iPhone 12 mini

14.1, 14.2, 14.3, 14.4

iPhone 6s

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone 6s Plus

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone 7

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone 7 Plus

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone 8

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone 8 Plus

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone SE (1st generation)

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone SE (2nd generation)

13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone X

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone Xs

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone Xs Max

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

iPhone Xʀ

12.4 ,13.5, 13.6, 13.7, 14.0, 14.1, 14.2, 14.3, 14.4

Demo video

Watch the video to see how to work with simulators 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.
Copy

Simulator app 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 SimulatorsWebDemoTest {

    public static ReportiumClient reportiumClient;
    protected static IOSDriver<IOSElement> 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", "iPhone 11");
        capabilities.setCapability("useVirtualDevice", true);

        capabilities.setCapability("automationName", "Appium");
        capabilities.setCapability("browserName", "safari");


        driver = new IOSDriver(new URL("https://" + host + "/nexperience/perfectomobile/wd/hub"), capabilities);

        PerfectoExecutionContext perfectoExecutionContext = new PerfectoExecutionContext.PerfectoExecutionContextBuilder()
                .withProject(new Project("Simulators", "1.0"))
                .withJob(new Job("IOS tests simulators", 45).withBranch("branch-name"))
                .withContextTags("Sanity")
                .withWebDriver(driver)
                .build();
        reportiumClient = new ReportiumClientFactory().createPerfectoReportiumClient(perfectoExecutionContext);
    }

    @Test
    public void SimulatorWebDemoTest() throws InterruptedException {


            reportiumClient.testStart("Simulators Web 'Demo' test", new TestContext("simulatorsWeb"));

            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.

Note

Before running your script, it is good practice to use the Get Licensee Information by Type API to check if a free simulator license is available. This step prevents script failures.

To configure and run your tests:

  1. 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 (14.3). The device name is specific (iPhone X).

    Copy

    Pure Appium script not running on Perfecto

    public static void main(String[] args) throws MalformedURLException, IOException {
        System.out.println("Run started");
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("browserName", "Safari");
        capabilities.setCapability("deviceName", "iPhone X");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "14.3");
        IOSDriver driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub/"), capabilities);
        driver.quit();
        System.out.println("Run ended");
    }
  2. 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.

  3. To run the test on a virtual device, add the capability useVirtualDevice and set it to true. 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.

    Copy

    Appium script running on Perfecto against a virtual device

    public 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(browserName, "", Platform.ANY);
            capabilities.setCapability("browserName", "Safari");
            capabilities.setCapability("deviceName", "iPhone X");
            capabilities.setCapability("platformName", "iOS");
            capabilities.setCapability("platformVersion", "14.3");
            capabilities.setCapability("securityToken", securityToken);//Line added
            capabilities.setCapability("useVirtualDevice", true);//Line added
            IOSDriver driver = new IOSDriver(new URL("https://" + cloudName + "/nexperience/perfectomobile/wd/hub"), capabilities);//Line modified
            driver.quit();
            System.out.println("Run ended");
        }
    Note

    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 the app capability for the main application and the otherApps capability for additional apps. For more information, see Supported Appium capabilities and the Appium information on General Capabilities.

  4. Save your test.
  5. To avoid script failure, check if a simulator license is available via the Get License Information by Type API. 
  6. If a license is available, run your script.

2 | View execution results

This section describes how to view and analyze the results of your test executions in Perfecto.

To view execution results:

  1. When your test execution has finished, go to your Perfecto cloud instance and click Analyze Reports to open the Test Analysis view.
  2. 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.

  3. Click the relevant test report.
  4. 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.