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

Last updated: Jan 19, 2020 10:42

In this example we call the Button.Click text command

Sample code:

Capabilities capabilities = driver.getCapabilities();
String executionId = (String) capabilities.getCapability("executionId");
String deviceID = (String) capabilities.getCapability("deviceName");
try {
       URL url = new URL("https://YourCloudNameHere.perfectomobile.com/services/executions/"+executionId+"?operation=command&securityToken=YourSecurityTokenHere&command=button-text&subcommand=click&param.deviceId="+deviceID+"&param.label=YourLabelHere&param.threshold=80&param.timeout=20");
       HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() != 200) {
       throw new RuntimeException("Failed : HTTP error code : "
                     + conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
       (conn.getInputStream())));
String output;
while ((output = br.readLine()) != null) {
       System.out.println(output);
}
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}


For more information on the button click text command see the following article: Button.Click text


Important note: In the above example you would need to replace in the URL your Perfecto lab name, security token and other parameters like label, threshold, etc.