8686public class AppiumDriver extends RemoteWebDriver implements MobileDriver ,
8787 ContextAware , Rotatable , FindsByIosUIAutomation ,
8888 FindsByAndroidUIAutomator , FindsByAccessibilityId , LocationContext ,
89- DeviceActionShortcuts , TouchShortcuts , InteractsWithFiles {
89+ DeviceActionShortcuts , TouchShortcuts , InteractsWithFiles , InteractsWithApps {
9090
9191 private final static ErrorHandler errorHandler = new ErrorHandler (
9292 new ErrorCodesMobile (), true );
@@ -231,8 +231,9 @@ public ExecuteMethod getExecuteMethod() {
231231 }
232232
233233 /**
234- * Reset the currently running app for this session
234+ * @see InteractsWithApps#resetApp()
235235 */
236+ @ Override
236237 public void resetApp () {
237238 execute (MobileCommand .RESET );
238239 }
@@ -293,48 +294,9 @@ public void hideKeyboard() {
293294 }
294295
295296 /**
296- * Hides the keyboard if it is showing. Available strategies are PRESS_KEY
297- * and TAP_OUTSIDE. One taps outside the keyboard, the other presses a key
298- * of your choosing (probably the 'Done' key). Hiding the keyboard often
299- * depends on the way an app is implemented, no single strategy always
300- * works.
301- *
302- * These parameters are only for iOS, and ignored by Android.
303- *
304- * @param strategy
305- * HideKeyboardStrategy
306- * @param keyName
307- * a String, representing the text displayed on the button of the
308- * keyboard you want to press. For example: "Done"
309- */
310- //Should be moved to the subclass
311- public void hideKeyboard (String strategy , String keyName ) {
312- String [] parameters = new String [] { "strategy" , "key" };
313- Object [] values = new Object [] { strategy , keyName };
314- execute (HIDE_KEYBOARD , getCommandImmutableMap (parameters , values ));
315- }
316-
317- /**
318- * Hides the keyboard by pressing the button specified by keyName if it is
319- * showing. This is an iOS only command.
320- *
321- * @param keyName
322- * The button pressed by the mobile driver to attempt hiding the
323- * keyboard
324- */
325- //Should be moved to the subclass
326- public void hideKeyboard (String keyName ) {
327- execute (HIDE_KEYBOARD , ImmutableMap .of ("keyName" , keyName ));
328- }
329-
330- /**
331- * Runs the current app as a background app for the number of seconds
332- * requested. This is a synchronous method, it returns after the back has
333- * been returned to the foreground.
334- *
335- * @param seconds
336- * Number of seconds to run App in background
297+ * @see InteractsWithApps#runAppInBackground(int)
337298 */
299+ @ Override
338300 public void runAppInBackground (int seconds ) {
339301 execute (RUN_APP_IN_BACKGROUND , ImmutableMap .of ("seconds" , seconds ));
340302 }
@@ -521,31 +483,9 @@ public void zoom(int x, int y) {
521483 }
522484
523485 /**
524- * In iOS apps, named TextFields have the same accessibility Id as their
525- * containing TableElement. This is a convenience method for getting the
526- * named TextField, rather than its containing element.
527- *
528- * @param name
529- * accessiblity id of TextField
530- * @return The textfield with the given accessibility id
531- */
532- //Should be moved to the subclass
533- public WebElement getNamedTextField (String name ) {
534- MobileElement element = (MobileElement ) findElementByAccessibilityId (name );
535- if (element .getTagName () != "TextField" ) {
536- return element .findElementByAccessibilityId (name );
537- }
538-
539- return element ;
540- }
541-
542- /**
543- * Checks if an app is installed on the device
544- *
545- * @param bundleId
546- * bundleId of the app
547- * @return True if app is installed, false otherwise
486+ * @see InteractsWithApps#isAppInstalled(String)
548487 */
488+ @ Override
549489 public boolean isAppInstalled (String bundleId ) {
550490 Response response = execute (IS_APP_INSTALLED ,
551491 ImmutableMap .of ("bundleId" , bundleId ));
@@ -554,59 +494,37 @@ public boolean isAppInstalled(String bundleId) {
554494 }
555495
556496 /**
557- * Install an app on the mobile device
558- *
559- * @param appPath
560- * path to app to install
497+ * @see InteractsWithApps#installApp(String)
561498 */
499+ @ Override
562500 public void installApp (String appPath ) {
563501 execute (INSTALL_APP , ImmutableMap .of ("appPath" , appPath ));
564502 }
565503
566504 /**
567- * Remove the specified app from the device (uninstall)
568- *
569- * @param bundleId
570- * the bunble identifier (or app id) of the app to remove
505+ * @see InteractsWithApps#removeApp(String)
571506 */
507+ @ Override
572508 public void removeApp (String bundleId ) {
573509 execute (REMOVE_APP , ImmutableMap .of ("bundleId" , bundleId ));
574510 }
575511
576512 /**
577- * Launch the app which was provided in the capabilities at session creation
513+ * @see InteractsWithApps#launchApp()
578514 */
515+ @ Override
579516 public void launchApp () {
580517 execute (LAUNCH_APP );
581518 }
582519
583520 /**
584- * Close the app which was provided in the capabilities at session creation
521+ * @see InteractsWithApps#closeApp()
585522 */
523+ @ Override
586524 public void closeApp () {
587525 execute (CLOSE_APP );
588526 }
589527
590- /**
591- * Lock the device (bring it to the lock screen) for a given number of
592- * seconds
593- *
594- * @param seconds
595- * number of seconds to lock the screen for
596- */
597- //Should be moved to the subclass (supposed to be in iOS)
598- public void lockScreen (int seconds ) {
599- execute (LOCK , ImmutableMap .of ("seconds" , seconds ));
600- }
601-
602- /**
603- * Simulate shaking the device This is an iOS-only method
604- */
605- //Should be moved to the subclass
606- public void shake () {
607- execute (SHAKE );
608- }
609-
610528 /**
611529 * Get settings stored for this test session It's probably better to use a
612530 * convenience function, rather than use this function directly. Try finding
0 commit comments