@@ -53,6 +53,15 @@ public AppiumDriver(URL remoteAddress, Capabilities desiredCapabilities){
5353 .put (RUN_APP_IN_BACKGROUND , postC ("/session/:sessionId/appium/app/background" ))
5454 .put (PERFORM_TOUCH_ACTION , postC ("/session/:sessionId/touch/perform" ))
5555 .put (PERFORM_MULTI_TOUCH , postC ("/session/:sessionId/touch/multi/perform" ))
56+ .put (IS_APP_INSTALLED , postC ("/session/:sessionId/appium/device/app_installed" ))
57+ .put (INSTALL_APP , postC ("/session/:sessionId/appium/device/install_app" ))
58+ .put (REMOVE_APP , postC ("/session/:sessionId/appium/device/remove_app" ))
59+ .put (LAUNCH_APP , postC ("/session/:sessionId/appium/app/launch" ))
60+ .put (CLOSE_APP , postC ("/session/:sessionId/appium/app/close" ))
61+ .put (END_TEST_COVERAGE , postC ("/session/:sessionId/appium/app/end_test_coverage" ))
62+ .put (LOCK , postC ("/session/:sessionId/appium/device/lock" ))
63+ .put (SHAKE , postC ("/session/:sessionId/appium/device/shake" ))
64+ .put (COMPLEX_FIND , postC ("/session/:sessionId/appium/app/complex_find" ))
5665 ;
5766 ImmutableMap <String , CommandInfo > mobileCommands = builder .build ();
5867
@@ -353,14 +362,14 @@ public void zoom(int x, int y) {
353362 multiTouch .perform ();
354363 }
355364
356- /**
365+ /**
357366 * In iOS apps, named TextFields have the same accessibility Id as their containing TableElement.
358367 * This is a convenience method for getting the named TextField, rather than its containing element.
359368 * @param name accessiblity id of TextField
360369 * @return The textfield with the given accessibility id
361370 */
362371 public WebElement getNamedTextField (String name ) {
363- RemoteWebElement element = (RemoteWebElement )findElementByAccessibilityId (name );
372+ RemoteWebElement element = (RemoteWebElement ) findElementByAccessibilityId (name );
364373 System .out .println ("tag name: " + element .getTagName ());
365374 if (element .getTagName () != "TextField" ) {
366375 MobileElement mobileElement = new MobileElement (element , this );
@@ -370,6 +379,82 @@ public WebElement getNamedTextField(String name) {
370379 return element ;
371380 }
372381
382+ /**
383+ * Checks if an app is installed on the device
384+ * @param bundleId bundleId of the app
385+ * @return True if app is installed, false otherwise
386+ */
387+ public boolean isAppInstalled (String bundleId ) {
388+ Response response = execute (IS_APP_INSTALLED , ImmutableMap .of ("bundleId" , bundleId ));
389+
390+ return Boolean .parseBoolean (response .getValue ().toString ());
391+ }
392+
393+ /**
394+ * Install an app on the mobile device
395+ * @param appPath path to app to install
396+ */
397+ public void installApp (String appPath ) {
398+ execute (INSTALL_APP , ImmutableMap .of ("appPath" , appPath ));
399+ }
400+
401+ /**
402+ * Remove the specified app from the device (uninstall)
403+ * @param bundleId the bunble identifier (or app id) of the app to remove
404+ */
405+ public void removeApp (String bundleId ) {
406+ execute (REMOVE_APP , ImmutableMap .of ("bundleId" , bundleId ));
407+ }
408+
409+ /**
410+ * Launch the app which was provided in the capabilities at session creation
411+ */
412+ public void launchApp () {
413+ execute (LAUNCH_APP );
414+ }
415+
416+ /**
417+ * Close the app which was provided in the capabilities at session creation
418+ */
419+ public void closeApp () {
420+ execute (CLOSE_APP );
421+ }
422+
423+ /**
424+ * Get test-coverage data
425+ * Android-only method
426+ * @param intent intent to broadcast
427+ * @param path path to .ec file
428+ */
429+ public void endTestCoverage (String intent , String path ) {
430+ ImmutableMap .Builder builder = ImmutableMap .builder ();
431+ builder .put ("intent" , intent ).put ("path" , path );
432+ execute (END_TEST_COVERAGE , builder .build ());
433+ }
434+
435+ /**
436+ * Lock the device (bring it to the lock screen) for a given number of seconds
437+ * @param seconds number of seconds to lock the screen for
438+ */
439+ public void lockScreen (int seconds ) {
440+ execute (LOCK , ImmutableMap .of ("seconds" , seconds ));
441+ }
442+
443+ /**
444+ * Simulate shaking the device
445+ */
446+ public void shake () {
447+ execute (SHAKE );
448+ }
449+
450+ public String complexFind (String [] complex ) {
451+ Response response = execute (COMPLEX_FIND , ImmutableMap .of ("selector" , complex ));
452+
453+ return response .toString ();
454+ }
455+
456+
457+
373458
374459 @ Override
375460 public WebDriver context (String name ) {
0 commit comments