8686public class AppiumDriver extends RemoteWebDriver implements MobileDriver ,
8787ContextAware , Rotatable , FindsByIosUIAutomation ,
8888FindsByAndroidUIAutomator , FindsByAccessibilityId , LocationContext ,
89- DeviceActionShortcuts , TouchShortcuts , InteractsWithFiles {
89+ DeviceActionShortcuts , TouchShortcuts , InteractsWithFiles , InteractsWithApps {
9090
9191private final static ErrorHandler errorHandler = new ErrorHandler (
9292new 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
236237public void resetApp () {
237238execute (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
338300public void runAppInBackground (int seconds ) {
339301execute (RUN_APP_IN_BACKGROUND , ImmutableMap .of ("seconds" , seconds ));
340302}
@@ -487,31 +449,9 @@ public void zoom(int x, int y) {
487449}
488450
489451/**
490- * In iOS apps, named TextFields have the same accessibility Id as their
491- * containing TableElement. This is a convenience method for getting the
492- * named TextField, rather than its containing element.
493- *
494- * @param name
495- * accessiblity id of TextField
496- * @return The textfield with the given accessibility id
497- */
498- //Should be moved to the subclass
499- public WebElement getNamedTextField (String name ) {
500- MobileElement element = (MobileElement ) findElementByAccessibilityId (name );
501- if (element .getTagName () != "TextField" ) {
502- return element .findElementByAccessibilityId (name );
503- }
504-
505- return element ;
506- }
507-
508- /**
509- * Checks if an app is installed on the device
510- *
511- * @param bundleId
512- * bundleId of the app
513- * @return True if app is installed, false otherwise
452+ * @see InteractsWithApps#isAppInstalled(String)
514453 */
454+ @ Override
515455public boolean isAppInstalled (String bundleId ) {
516456Response response = execute (IS_APP_INSTALLED ,
517457ImmutableMap .of ("bundleId" , bundleId ));
@@ -520,59 +460,37 @@ public boolean isAppInstalled(String bundleId) {
520460}
521461
522462/**
523- * Install an app on the mobile device
524- *
525- * @param appPath
526- * path to app to install
463+ * @see InteractsWithApps#installApp(String)
527464 */
465+ @ Override
528466public void installApp (String appPath ) {
529467execute (INSTALL_APP , ImmutableMap .of ("appPath" , appPath ));
530468}
531469
532470/**
533- * Remove the specified app from the device (uninstall)
534- *
535- * @param bundleId
536- * the bunble identifier (or app id) of the app to remove
471+ * @see InteractsWithApps#removeApp(String)
537472 */
473+ @ Override
538474public void removeApp (String bundleId ) {
539475execute (REMOVE_APP , ImmutableMap .of ("bundleId" , bundleId ));
540476}
541477
542478/**
543- * Launch the app which was provided in the capabilities at session creation
479+ * @see InteractsWithApps#launchApp()
544480 */
481+ @ Override
545482public void launchApp () {
546483execute (LAUNCH_APP );
547484}
548485
549486/**
550- * Close the app which was provided in the capabilities at session creation
487+ * @see InteractsWithApps#closeApp()
551488 */
489+ @ Override
552490public void closeApp () {
553491execute (CLOSE_APP );
554492}
555493
556- /**
557- * Lock the device (bring it to the lock screen) for a given number of
558- * seconds
559- *
560- * @param seconds
561- * number of seconds to lock the screen for
562- */
563- //Should be moved to the subclass (supposed to be in iOS)
564- public void lockScreen (int seconds ) {
565- execute (LOCK , ImmutableMap .of ("seconds" , seconds ));
566- }
567-
568- /**
569- * Simulate shaking the device This is an iOS-only method
570- */
571- //Should be moved to the subclass
572- public void shake () {
573- execute (SHAKE );
574- }
575-
576494/**
577495 * Get settings stored for this test session It's probably better to use a
578496 * convenience function, rather than use this function directly. Try finding
0 commit comments