Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Jul 16, 2020 12:14

Perfecto supports virtual mobile devices using pure Appium. In addition to Appium capabilities, you can define the following capabilities for virtual mobile devices.

Capability nameDescriptionValue/example
appiumVersionThe Appium version to use for your script. By default, this is the latest version supported.1.12.0, 1.15.1, 1.17.0
browserName**

If the script runs on a browser, the name of the mobile web browser.

Safari, Chrome
bundleId**

(iOS only) The case-sensitive bundle identifier of the application. Mandatory when you want to use a specific app.

io.appium.TestApp
deviceName

The kind of virtual device to use. Can be specific or generic. If you do not specify a device name, Perfecto launches any relevant virtual device. Regular expressions are also supported as a value.

Note: In support of pure Appium, this parameter accepts the values iPhone Simulator and iPad Simulator. If your tests include these values, you can run them as they are. However, you must make sure that useVirtualDevice is omitted or set to true. Otherwise, an error occurs.

iPhone 11, iPad
platformName*The device operating system.iOS, Android (not yet supported)
platformVersionThe version of the device operating system. If not provided, Perfecto defaults to the latest OS version available. Regular expressions are also supported as a value.12.0, 13.0, 13.3
useVirtualDevice*

Perfecto-specific capability. By default, Perfecto works with real devices. Set to true to work with simulators or emulators. This is the preferred method of working with virtual mobile devices.

True or false

* Mandatory capability

** You must include either bundleId or browserName.

For example, to modify a script that runs against a real iOS device to run against a simulator, you only need to add the capability useVirtualDevice and set it to true (line 16 in script 2), provided the script includes the platformName capability and either the bundleId or browserName capability.

1 | Appium script running on Perfecto against a real device
public static void main(String[] args) throws MalformedURLException, IOException {
        System.out.println("Run started");

        String cloudName = System.getProperty("cloudName");
		String securityToken = System.getProperty("securityToken");

        String browserName = "mobileOS";
        DesiredCapabilities capabilities = new DesiredCapabilities(browserName, "", Platform.ANY);

        capabilities.setCapability("browserName", "Safari");
        capabilities.setCapability("deviceName", "iPhone X");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "13.3");

        capabilities.setCapability("securityToken", securityToken);

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

        driver.quit();

        System.out.println("Run ended");
}
2 | 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");
		String securityToken = System.getProperty("securityToken");

        String browserName = "mobileOS";
        DesiredCapabilities capabilities = new DesiredCapabilities(browserName, "", Platform.ANY);

        capabilities.setCapability("browserName", "Safari");
        capabilities.setCapability("deviceName", "iPhone X");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "13.3");

		capabilities.setCapability("securityToken", securityToken);
        capabilities.setCapability("useVirtualDevice", true);//Line added

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

        driver.quit();

        System.out.println("Run ended");
    }