Pcloudy Mobile Commands
  • 12 Aug 2024
  • 3 Minutes to read
  • Dark
    Light

Pcloudy Mobile Commands

  • Dark
    Light

Article summary

Overview
Use Appium Client methods to use pCloudy API's in automation scripts. By using the code mentioned below, users can send commands to the mobile devices used for automation testing. This will help users to use pCloudy features in their test automation to bring more values to functional tests.

1. Android - To Execute ADB command on booked Device

Command
driver.executeScript("pCloudy_executeAdbCommand", "ADB_COMMAND");

Example
Object obj = driver.executeScript("pCloudy_executeAdbCommand", "adb devices"); System.out.println("@Output: " + obj);

2. Android - To Set Device Location

Command
Map<String, Object> params = new HashMap<>();
params.put("latitude", "28.6139");
params.put("longitude", "77.2088");
Thread.sleep(20000);
System.out.println(driver.executeScript("pCloudy_setAndroidLocation",params));
Thread.sleep(20000);

Example
Map<String, Object> params = new HashMap<>();
params.put("latitude", "28.6139");
params.put("longitude", "77.2088");
Thread.sleep(20000);
System.out.println(driver.executeScript("pCloudy_setAndroidLocation",params));
Thread.sleep(20000);

3. Android/iOS - To toggle device location.

Command
driver.executeScript("pCloudy_switchDeviceLocation", "true/false");

Example
Object obj1 = driver.executeScript("pCloudy_switchDeviceLocation", "true");

4. Android - To toggle Wifi

Command
driver.executeScript("pCloudy_enablewifi", "true/false");

Example
driver.executeScript("pCloudy_enablewifi", "true");

5. Android/iOS - To get a video for every test case during Appium session.

Command
Map<String, Object> params = new HashMap<>(); params.put("enableRecord", true); System.out.println(driver.executeScript("mobile:video:record",params));

Example
Map<String, Object> params = new HashMap<>(); params.put("enableRecord", true); System.out.println(driver.executeScript("mobile:video:record",params));

6. Android/iOS - To stop a video generation during Appium session.

Command
Map<String, Object> params = new HashMap<>(); params.put("enableRecord", false); System.out.println(driver.executeScript("mobile:video:record",params));

Example
Map<String, Object> params = new HashMap<>(); params.put("enableRecord", false); System.out.println(driver.executeScript("mobile:video:record",params));

7. Android/iOS - To get a report link.

Command
driver.executeScript("pCloudy_getReportLink");

Example
String link = (String) driver.executeScript("pCloudy_getReportLink"); System.out.println(link);

8. Android/iOS - To get the link to see the live view of stream based devices.

Command
Map<String, Object> params = new HashMap<>(); params.put("getDeviceUrl", true); System.out.println(driver.executeScript("mobile:device:url",params));

Example
Map<String, Object> params = new HashMap<>(); params.put("getDeviceUrl", true); System.out.println(driver.executeScript("mobile:device:url",params));

9. Android - Biometric automation on Android devices.

Command
Map<String, Object> params = new HashMap<>(); params.put("auth", true); System.out.println(driver.executeScript("mobile:fingerprint:auth",params));

Example
Map<String, Object> params = new HashMap<>(); params.put("auth", true); System.out.println(driver.executeScript("mobile:fingerprint:auth",params));

10. iOS - Biometric automation on iOS devices.

Command
Map<String, Object> params = new HashMap<>(); params.put("auth", true); System.out.println(driver.executeScript("mobile:biometric:auth",params));

Example
Map<String, Object> params = new HashMap<>(); params.put("auth", true); System.out.println(driver.executeScript("mobile:biometric:auth",params));

11. Android/iOS - To inject QR code image.

Command
"Map<String, Object> params = new HashMap<>();
params.put(""image"", ""QR_code_G.png"");
Thread.sleep(2000);
System.out.println(driver.executeScript(""pCloudy_injectImage"",params));
Thread.sleep(2000"

Example
"Map<String, Object> params = new HashMap<>();
params.put(""image"", ""QR_code_G.png"");
Thread.sleep(2000);
System.out.println(driver.executeScript(""pCloudy_injectImage"",params));
Thread.sleep(2000);"

12. Android/iOS - To start network simulation.

Note - User can get information about all the network profiles available according to that user can simulate the network.
.
Command
Map<String, Object> params = new HashMap<>(); params.put("profileName", "4G-LTE-Advanced"); System.out.println(driver.executeScript("mobile:network:start",params));

Example
Map<String, Object> params = new HashMap<>(); params.put("profileName", "4G-LTE-Advanced"); System.out.println(driver.executeScript("mobile:network:start",params));

13. Android/iOS - To reset network profiles.

Command
Map<String, Object> params = new HashMap<>(); params.put("profileName", "4G-LTE-Advanced"); System.out.println(driver.executeScript("mobile:network:stop",params));

Example
Map<String, Object> params = new HashMap<>(); params.put("profileName", "4G-LTE-Advanced"); System.out.println(driver.executeScript("mobile:network:stop",params));

14. Android/iOS - To get all the text present in an image.

Command
Map<String, Object> params = new HashMap<>(); driver.executeScript("mobile:ocr:text",params);

15. Android/iOS - To compare and find the difference between two images.

Command
Map<String, Object> params = new HashMap<>(); params.put("baseImageId", "firstImageId"); params.put("secondImageId", "secondImageId"); driver.executeScript("mobile:visual:imageDiff",params);

16. Android/iOS - To verify if any word exists or not in an image.

Command
Map<String, Object> params = new HashMap<>(); params.put("imageId", "ID"); params.put("word", "abc"); System.out.println(driver.executeScript("mobile:ocr:textExists",params));

17. Android/iOS - To find the coordinates of a word.

Command
Map<String, Object> params = new HashMap<>(); params.put("imageId", "ID"); params.put("word", "abc"); System.out.println(driver.executeScript("mobile:ocr:coordinate",params));

18. Android/iOS - To start the transaction execution with HAR file.

Command
Map<String, Object> params = new HashMap<>(); params.put("transactionName", "Name of transaction file"); params.put("enableHar", true); params.put("harFileName", "Har file Name"); driver.executeScript("mobile:transaction:start",params);

19. Android/iOS - To stop the transaction execution.

Command
Map<String, Object> params = new HashMap<>(); driver.executeScript("mobile:transaction:stop",params);

20. Android/iOS - To rotate the device in landscape mode.

Command
Map<String, Object> params = new HashMap<>(); params.put("orientation", "L"); System.out.println(driver.executeScript("mobile:device:rotate",params));

21. Android/iOS - To rotate the device in portrait mode.

Command
Map<String, Object> params1 = new HashMap<>(); params1.put("orientation", "P"); System.out.println(driver.executeScript("mobile:device:rotate",params1));

22. Android/iOS - To close app.

Command
"Map<String, Object> params = new HashMap<>();
params.put(""name"", ""com.pcloudy.appiumdemo"");
Thread.sleep(3000);
System.out.println(driver.executeScript(""mobile:application:close"",params));
Thread.sleep(3000);"

Example
"Map<String, Object> params = new HashMap<>();
params.put(""name"", ""com.pcloudy.appiumdemo"");
Thread.sleep(3000);
System.out.println(driver.executeScript(""mobile:application:close"",params));
Thread.sleep(3000);"

23. Android/iOS - To open app.

Command
"Map<String, Object> params1 = new HashMap<>();
params.put(""name"", ""com.pcloudy.appiumdemo"");
params.put(""fileName"", ""pCloudyAppiumDemo-1682759228.apk"");
Thread.sleep(3000);
System.out.println(driver.executeScript(""mobile:application:open"",params));
Thread.sleep(3000);"

Example
"Map<String, Object> params1 = new HashMap<>();
params.put(""name"", ""com.pcloudy.appiumdemo"");
params.put(""fileName"", ""pCloudyAppiumDemo-1682759228.apk"");
Thread.sleep(3000);
System.out.println(driver.executeScript(""mobile:application:open"",params));
Thread.sleep(3000);"

24. Android - To create contact.

Command
"Map<String, Object> params = new HashMap<>();
params.put(""name"",""xyz"");
params.put(""phone"",""123567890"");
params.put(""email"",""proxy@gmail.com"");
System.out.println(driver.executeScript(""mobile:createContact"",params));
Thread.sleep(10000);"

Example
"Map<String, Object> params = new HashMap<>();
params.put(""name"",""xyz"");
params.put(""phone"",""1234567890"");
params.put(""email"",""proxy@gmail.com"");
System.out.println(driver.executeScript(""mobile:createContact"",params));
Thread.sleep(10000);"

25. Android/iOS - To Tap.

Command
"Map<String, Object> params = new HashMap<>();
params.put(""location"", ""140,640,0,0"");
Thread.sleep(2000);
System.out.println(driver.executeScript(""mobile:touch:tap"",params));
Thread.sleep(2000);"

Example
"Map<String, Object> params = new HashMap<>();
params.put(""location"", ""140,640,0,0"");
Thread.sleep(2000);
System.out.println(driver.executeScript(""mobile:touch:tap"",params));
Thread.sleep(2000);"

26. Android/iOS - To Type Text

Command
"Map<String, Object> params = new HashMap<>();
params.put(""text"", ""Hello Bangalore"");
Thread.sleep(1000);
System.out.println(driver.executeScript(""mobile:typetext"",params));
Thread.sleep(2000);"

Example
"Map<String, Object> params = new HashMap<>();
params.put(""text"", ""Hello Bangalore"");
Thread.sleep(1000);
System.out.println(driver.executeScript(""mobile:typetext"",params));
Thread.sleep(2000);"

27. Android - To Biometric automation on Android devices.

Command
"Object obj1 = driver.executeScript(""pCloudy_biometric"", true/false);
Thread.sleep(5000);
System.out.println(""@Output: "" + obj1);
Thread.sleep(5000);"

Example
"Object obj1 = driver.executeScript(""pCloudy_biometric"", true/false);
Thread.sleep(5000);
System.out.println(""@Output: "" + obj1);
Thread.sleep(5000);"


Was this article helpful?

What's Next