Selecting a single device during execution

From within your action lines, you can control which device your test is to execute on. The built-in assign device action is used to specify a target device upon which the subsequent action lines are to be run.

Important: 
With this method, only a single device is selected and run at a time. You are required to terminate the connection the current device-under-test, before executing the remaining tests on other devices.

To start automated mobile web testing on a device in a given WebDriver based cloud service, declare the following action lines in your test:

  1. Use the assign device built-in action to define a list of desired capabilities, which are sets of keys and values sent to the Appium server in JSON format.

    Notes: 
    • See the Desired Capabilities documentation for the list of capabilities available for Appium.
    • Along with the capabilities of Appium, some WebDriver based cloud services might have their own set of capabilities. For example, Testdroid, several additional Testdroid Desired Capabilities are also provided (learn more). Also ensure that your Testdroid Cloud project’s type must be either Appium Android client side or Appium iOS client side

    For example: You’d like to automate mobile web application testing on Chrome in Testdroid.

    • Your set of desired capabilities should be defined as follows.

      • For specific Testdroid capabilities:
        • testdroid_username: Email registered at Testdroid Cloud. Example: [email protected].
        • testdroid_password: Password for your Testdroid Cloud account. Example: p4s$w0rd
        • testdroid_target: Target test type. Example: chrome, which invokes Google Chrome browser during mobile web application testing.
        • testdroid_project: Project name that will be displayed on Web UI. Example: Chrome Android Project.
        • testdroid_testrun: Name given to each Test Run under a Project. Example: Test Run 1.
        • testdroid_device: The device name that uniquely identifies a device on Testdroid Cloud. Example: Sony Xperia Z C6603.
      • For Appium server capabilities:
        • deviceName: The kind of mobile device to use. For example: Android Device
        • platformName: Which mobile OS platform to use. For example: Android
        • browserName: Name of mobile web browser to automate. For example: chrome
      • Your JSON string is as follows:
      {"deviceName":"Android Device",
      "platformName":"Android",
      "browserName":"chrome",
      "testdroid_username": "[email protected]", 
      "testdroid_password": "p4s$w0rd", 
      "testdroid_target": "chrome",
      "testdroid_project": "  `Chrome Android Project`", 
      "testdroid_testrun": "Test Run 1",
      "testdroid_device": "Sony Xperia Z C6603"
      
    • Specify URL Appium server of the given WebDriver based cloud service. For example: Testdroid, the URL Appium server is http://appium.testdroid.com/wd/hub

    • assign device should resemble the following.

    ```
                          url                                   capability                                        name   
    assign device         http://appium.testdroid.com/wd/hub    {"deviceName":"Android Device",                   Xperia Z
                                                                 "platformName":"Android",
                                                                 "browserName":"chrome",
                                                                 "testdroid_username": "[email protected]",
                                                                 "testdroid_password": "p4s$w0rd", 
                                                                 "testdroid_target": "chrome",
                                                                 "testdroid_project": "  `Chrome Android Project`", 
                                                                 "testdroid_testrun": "Test Run 1",
                                                                 "testdroid_device": "Sony Xperia Z C6603"}    
    ```
    
  2. Make a connection to the target device via the connect device built-in action, as specified by its logical name.

    Notes: 
    The name is established in advance by the assign device action, which assigns a logical name to a mobile device.

                           name         session id
    connect device         Xperia Z     >>Xperia_Z_sessionID
    
  3. Employ the use device built-in action to use the device to initiate automated tests. The invoked device is specified by its session ID.

    Notes: 
    The session ID specified in the session id argument is retrieved via the connect device action.

                         session id
    use device           #Xperia_Z_sessionID
    
  4. Now, you’re ready to begin performing your automated web-based tests on the target device.

  5. When you no longer need to continue the tests on the target device, it is highly recommended that you terminate the connection with the target device by using the disconnect device built-in action.

                               session id
    disconnect device          #Xperia_Z_sessionID
    
  6. When you’d like to switch back to the host machine to continue the remaining tests, use the use host machine built-in action.

  7. Overall, your snippet of test should resemble the following.

    //Define desired capabilities
    
                            url                                 capability                                         name   
    assign device           http://appium.testdroid.com/wd/hub  {"deviceName":"Android Device",                    Xperia Z
                                                                 "platformName":"Android",
                                                                 "browserName":"chrome",
                                                                 "testdroid_username": "[email protected]",
                                                                 "testdroid_password": "p4s$w0rd", 
                                                                 "testdroid_target": "chrome",
                                                                 "testdroid_project": "  `Chrome Android Project`", 
                                                                 "testdroid_testrun": "Test Run 1",
                                                                 "testdroid_device": "Sony Xperia Z C6603"}   
    
    //Connect to the target device
                             name                                session id
    connect device           Xperia Z                            >>Xperia_Z_sessionID
    
    //Use the target device
                             session id
    use device         #Xperia_Z_sessionID
    
    //Implement action lines to perform automated mobile web-based testing
    
    //Disconnect the target device
                              session id
    disconnect device   #Xperia_Z_sessionID
    

Copyright © 2023 LogiGear Corporation. All rights reserved. LogiGear is a registered trademark, and Action Based Testing and TestArchitect are trademarks of LogiGear Corporation. All other trademarks contained herein are the property of their respective owners.

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1(800) 322-0333