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

Last updated: Apr 01, 2020 14:50

For the purpose of script development and debugging, you can open a device in the Perfecto Lab and share that session with your favorite IDE. Session sharing allows you to work interactively on the device in the Perfecto Lab while simultaneously executing an Appium or Selenium script from your IDE. 

Step-by-step instructions

Watch the following video to see how to copy a session ID and include it in a script.


On this page:


To share the session ID:

  1. In the Perfecto Lab, open a mobile device.

  2. On the device tab, in the device toolbar, click the Copy Session ID button .

  3. In the Copy session ID form, copy the session ID or capability code sample to the clipboard.

  4. In the IDE you are using, add the deviceSessionID capability to your script.

    Session ID example
    3d3718b8-0700-4ecb-99dd-71c1def7138b
    deviceSessionId capability example
    capabilities.setCapability("deviceSessionId", "3d3718b8-0700-4ecb-99dd-71c1def7138b");
  5. If you have 2 or more devices open, also specify the device ID to use (same as you would do if running a test on a device without the device being open in the Perfecto Lab), as follows:

    1. On the device toolbar, click the information icon .

    2. In the device info form, on the Device tab, copy the Device ID.
    3. In the IDE you are using, add the deviceName capability to your script.

      deviceName capability example
      capabilities.setCapability("deviceName", "00008030-001D29661488802E");
  6. Run your test. This performs all your test step on the device in real-time.

Notes:

  • When you use a new device or start a new Perfecto Lab session, you need a new session ID.
  • If you intend to run your script outside of session sharing, before committing, remove these capabilities from the script code. Otherwise, your script will fail.

Limitations

When the deviceSessionId capability is used along with other capabilities, the only capability that takes effect is deviceSessionId. Other capabilities (such as install app or open app) are ignored. You can use the Perfecto driver.executeScript to code these and other actions (for more information, see Execute proprietary functions). For example, if you want to install an application as part of the shared session, you can use the following code: 
//declare the Map for script parameters
Map<String, Object> params = new HashMap<>();
  
params.put("file", "PRIVATE:applications/Errands.ipa");
params.put("instrument", "noinstrument");
driver.executeScript("mobile:application:install", params);