Selecting a single cloud device during execution
From within your action lines, you can control which cloud device your test is to execute on. The built-in assign cloud device action is used to specify a target cloud device upon which the subsequent action lines are to be run.
Ensure that the following requirements are met before implementing automated mobile web testing on a cloud device in the Remote TestKit cloud service.
- In the Remote TestKit cloud service, rent an iOS device and enable Xcode Connector. (Learn more.)
- Run Appium server on your local host.
- Install the SafariLauncher application.
Use the assign cloud 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. You can define as many capabilities as you need (learn more). However, it is recommended that your JSON string contain the following basic capabilities including.
- deviceName
- platformName
- browserName
For example: You rent an iPhone 6s in Remote TestKit to automate mobile web applications, your set of desired capabilities should be defined as follows.
deviceName: UDID of the rented device (learn more). For example:
002ebf12-a125-5ddf-a739-67c3c5d20177
.platformName:
iOS
browserName:
Safari
, which invokes Safari browser during mobile web application testing.JSON string is as follows:
{"deviceName" : " `002ebf12-a125-5ddf-a739-67c3c5d20177`", "platformName" : "iOS", "browserName" : "Safari"}
Specify local URL Appium server:
- The format is in the form of
http://<server_address>:<port_number>/wd/hub/
- For example:
http://127.0.0.1:4723/wd/hub/
- The format is in the form of
assign device should resemble the following.
url capability name assign cloud device `http://127.0.0.1:4723/wd/hub/` {"deviceName" : " `002ebf12-a125-5ddf-a739-67c3c5d20177`", iPhone 6s "platformName" : "iOS", "browserName" : "Safari"}
Make a connection to the target cloud device via the connect cloud device built-in action, as specified by its logical name.
Note:The name is established in advance by the assign cloud device action, which assigns a logical name to a mobile cloud device.name session id connect cloud device iPhone 6s >>iPhone6s_sessionID
Employ the use cloud device built-in action to use the cloud device to initiate automated tests. The invoked cloud device is specified by its session ID.
Note:The session ID specified in the session id argument is retrieved via the connect cloud device action.session id use cloud device #iPhone6s_sessionID
Now, you’re ready to begin performing your automated web-based tests on the target cloud device.
When you no longer need to continue the tests on the target cloud device, it is highly recommended that you terminate the connection with the target device by using the disconnect cloud device built-in action.
session id disconnect cloud device #iPhone6s_sessionID
When you’d like to switch back to the host machine to continue the remaining tests, use the use host machine built-in action.
Overall, your snippet of test should resemble the following.
//Define desired capabilities url capability name assign cloud device `http://127.0.0.1:4723/wd/hub/` {"deviceName" : " `002ebf12-a125-5ddf-a739-67c3c5d20177`", iPhone 6s "platformName" : "iOS", "browserName" : "Safari"} //Connect to the target cloud device name session id connect cloud device iPhone 6s >>iPhone6s_sessionID //Use the target cloud device session id use cloud device #iPhone6s_sessionID //Implement action lines to perform automated mobile web-based testing //Disconnect the target device session id disconnect cloud device #iPhone6s_sessionID