Top Appium Commands every Developer must know

On This Page What is Appium?Appium Commands Cheat Sheet

February 10, 2026 · 11 min read · Tool Comparison

Top Appium Commands every Developer must know

Mobile Application examination is either done manually or automatize. Open-source tools such as Appium can automate wandering application tests.

Overview

What is Appium?

Appium is an open-source test mechanisation puppet for try Mobile Applications. It supports various platforms, such as iOS, Android, and Windows.

Categories of Important Appium Commands and Methods

  1. Initialize Desired Capabilities: Define twist, platform, and app scope to start a session.
  2. Locator Strategies: Identify UI constituent using XPath, ID, class name, and more.
  3. App & amp; Device Actions: Perform action like tap, swipe, scroll, and keyboard input.
  4. Advanced Commands – iOS & amp; Android: Execute platform-specific gestures and activeness.
  5. ​​Execute Methods for Extended Functionality: Trigger mobile-specific actions like unlocking a device, simulating fingerprint scan, or toggle network settings.
  6. Advanced Commands – iOS: Run iOS-exclusive feature like Touch ID or background apps.
  7. Advanced Commands – Android: Provide greater control over device behavior, allowing testers to imitate actual conditions and validate responses.
  8. App Management – iOS: Install, uninstall, and launch apps on iOS devices.
  9. App Management – Android: Manage APKs and app activities on Android devices.

This article provides acheat sheet of the top Appium biddingevery developer must know.

What is Appium?

is an open-source tool for testing Mobile Applications. It supports respective platforms, such as iOS, Android, and Windows.

It allows user to test respective eccentric of Mobile Applications, such as:

  • Native Apps:These are native to a particular program and are written using Android, iOS, or Windows SDKs.
  • Web Apps: These are pure web apps accessed via aboriginal browsers like Chrome, Safari, Firefox, etc.
  • Intercrossed Apps:These are an amalgamation of both Native and Web apps.

Learn More:

Appium offers. That is, a individual API deeds for both Android and iOS platforms. This means developer or testers can use the like code for all platforms. Like Appium allows examiner to write test script in different programming languages such as,, Ruby, PHP, JavaScript, and C #.

Also Read:

Appium Commands Cheat Sheet

Appiumrender various commands and method for automating mobile applications across Android and iOS platforms. These dictation allow testers to interact with mobile apps like a existent exploiter.

Below is a handy cheat sheet covering usually used Appium commands to race up your mobile automation workflow.

Pre-Requisites

Before starting with with Appium, you would need to follow these steps:

1. Ensure that theJava Libraryis installed for Appium.

2. Download and instalMavenfollowing the steps fromthe official site.

3. Import statements for several commands can be as follows. Add them to your program as per the commands in use:

  • import org.openqa.selenium.WebElement;
  • import org.openqa.selenium.JavascriptExecutor;
  • import org.openqa.selenium.support.FindBy;
  • meaning org.openqa.selenium.support.FindBys;
  • import org.openqa.selenium.remote.RemoteWebElement;
  • significance org.openqa.selenium.remote.DesiredCapabilities;
  • import org.openqa.selenium.Dimension;
  • import org.openqa.selenium.By;
  • import org.openqa.selenium.Keys;
  • import org.openqa.selenium.WebDriver;
  • importee io.appium.java_client.pagefactory. *;
  • importee io.appium.java_client.ios.IOSElement;
  • import io.appium.java_client.AppiumDriver;
  • import io.appium.java_client.MobileElement;
  • import io.appium.java_client.android.AndroidDriver;
  • importation io.appium.java_client.ios.IOSDriver;
  • import io.appium.java_client.MobileElement;
  • signification io.appium.java_client.MultiTouchAction;
  • import io.appium.java_client.TouchAction;
  • import io.appium.java_client.android.AndroidElement;

Here are the Basic Appium Commands in the Java version:

1. Initialize Desired Capabilities

Desired Capabilities define the properties of the mobile device and app under examination (like platform name, device name, app route, etc.).

These capableness are required to part an Appium session and connect to the target gimmick or emulator.

  • Create local Appium Server instance
appiumLocalService = new AppiumServiceBuilder () .usingAnyFreePort () .build ();
  • Start local Appium Server instance
appiumLocalService.start ();
  • iOS Capabilities

Example:

DesiredCapabilities crest = new DesiredCapabilities (); caps.setCapability (“ automationName ”, `` XCUITest ''); caps.setCapability (“ deviceName ”, `` iPhone 13 ''); caps.setCapability (“ platformName ”, `` iOS ''); caps.setCapability (“ platformVersion ”, `` 15.6 '');
  • Android Capabilities

Example:

DesiredCapabilities crest = new DesiredCapabilities (); caps.setCapability (“ automationName ”, `` UiAutomator2 ''); caps.setCapability (“ deviceName ”, `` Samsung ''); caps.setCapability (“ platformName ”, `` Android ''); caps.setCapability (“ platformVersion ”, `` 7.1 '');
  • Install an app on iOS
DesiredCapabilities caps = new DesiredCapabilities (); caps.setCapability (“ app ”, `` path/to/TestApp.app.zip '');
  • Install an app on Android

Example:

DesiredCapabilities cap = new DesiredCapabilities (); caps.setCapability (“ appPackage ”, `` com.android.calculator2 ''); caps.setCapability (“ appActivity ”, `` com.android.calculator2.Calculator ''); caps.setCapability (“ app ”, `` path/to/TestApp.apk '');
  • Start browser on iOS
DesiredCapabilities cap = new DesiredCapabilities (); caps.setCapability (“ browserName ”, `` Safari '');
  • Start browser on Android
DesiredCapabilities caps = new DesiredCapabilities (); caps.setCapability (“ browserName ”, `` Chrome '');
  • Initialize iOS driver on the local waiter illustration
driver = new IOSDriver & lt; IOSElement & gt; (appiumLocalService, caps);
  • Initialize Android driver on the local server instance
driver = new AndroidDriver & lt; AndroidElement & gt; (appiumLocalService, cap);
  • Set WebView Context for Hybrid Apps
driver.context (driver.getContextHandles () .stream () .filter (c - & gt; c.contains (`` WEBVIEW '')) .findFirst () .orElse (null));
  • Initialize iOS remote driver

helps in do a meshwork request to a Selenium hub to start a driver session since Appium run on the Client-Server model. It is not recommended to use the Remote WebDriver immediately. Hence, it is used with the IOS Driver and Android Driver.

IOS and Android Drivers inherit from Appium Driver. They add additional use that are useful to the context of mobile mechanization on IOS and Android devices severally through Appium.

In the example below, the URL is pointing to the local host.

Note:You can include the URL which level to your outside web server as well here.

driver = new IOSDriver & lt; IOSElement & gt; (new URL (``http: //0.0.0.0:4723/wd/hub``), caps); //This URL points to the local waiter
  • Initialize Android remote driver
driver = new AndroidDriver & lt; AndroidElement & gt; (new URL (``http: //127.0.0.1:4723/wd/hub``), caps); //This URL point to the local server

Read More:

2. Locator Strategies

To interact with app elements, Appium uses different locater scheme such as id, className, xpath, accessibilityId, and AndroidUIAutomator or iOSPredicateString.

Learn More:

Choosing the correct strategy assure honest and fast element detection.

  • Locate by ID
driver.findElementById (`` android: id/button '');
  • Locate by Accessibility ID
driver.findElementByAccessibilityId (`` Views '');
  • Locate by Class (Single Element)
driver.findElementByClassName (`` android.widget.CheckBox '');
  • Locate by Class (Multiple Elements)
driver.findElementsByClassName (`` android.widget.CheckBox '');
  • Locate by AndroidUIAutomator (UI Automator 2)
driver.findElementByAndroidUIAutomator (`` new UiSelector () .textContains (\ '' BUTTON\ ''); '');
  • Locate by Image
driver.findElementByImage (base64EncodedImageFile);
  • Locate by XPath & # 8211; iOS
driver.findElementByXPath (`` (//XCUIElementTypeButton) [1] '');
  • Locate by XPath & # 8211; Android
driver.findElementByXPath (`` // * [@ resource-id='com.example.android.apis: id/button '] '');

Also Read:

3. App & amp; Device Actions

This family includes essential action like clicking, typing, scroll, swiping, and interacting with system features (e.g., locking the device or rotating the blind).

Also Read:

These simulate real user behavior for robust.

  • For Handling Alert
driver.switchTo () .alert () .accept (); driver.switchTo () .alert () .dismiss ();
  • For Basic Input operations
element.click (); element.clear (); element.sendKeys (`` textToType '');
  • For Changing orientation
driver.rotate (ScreenOrientation.LANDSCAPE);
  • For Setting text on clipboard
driver.setClipboardText (`` 9876 '', `` UserText ''); String clipboard = driver.getClipboardText ();
  • For Mobile gestures using TouchAction
TouchAction touchAction = new TouchAction (driver);
  • For Tapping:
touchAction.tap (TapOptions.tapOptions () .withPosition (PointOption.point (x, y));
  • For Pressing:
touchAction.press (PointOption.point (x, y));

Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.

  • For Waiting:
touchAction.waitAction (WaitOptions .waitOptions (Duration.ofMillis (200)));
  • For Moving:
touchAction.moveTo (PointOption.point (x, y));
  • For Long Press:
touchAction.longPress (PointOption.point (x, y));
  • For Releasing and Performing:
touchAction.release (); touchAction.perform ();
  • For Toggle services
driver.toggleAirplaneMode (); driver.toggleData (); driver.toggleLocationServices (); driver.toggleWifi ();
  • For Soft keyboard actions
driver.isKeyboardShown (); // returns boolean driver.hideKeyboard ();
  • For Locking twist
driver.isDeviceLocked (); // homecoming boolean driver.lockDevice (); driver.unlockDevice ();
  • For Notifications
driver.openNotifications ();
  • For File actions
driver.pushFile (`` /data/local/tmp/file '', new File (`` path/to/file '')); driver.pullFile (`` /path/to/device/file ''); // returns byte [] driver.pullFolder (`` /path/to/device ''); // returns byte []
  • For getting System time
driver.getDeviceTime (); // returns String

4. Advanced Commands & # 8211; both iOS & amp; Android

These are platform-agnostic command like trade contexts (for intercrossed apps), do multi-touch gesture, interact with notifications, or capturing device log that are important for deep functional and UI proof.

  • For Multitouch actions
TouchAction actionOne = new TouchAction (driver);
  • For Pressing at a point:
actionOne.press (PointOption.point (10, 10));
  • For Moving to a point:
actionOne.moveTo (PointOption.point (10, 100));
  • For Releasing
actionOne.release ();

Example:

TouchAction actionTwo = new TouchAction (driver); actionTwo.press (PointOption.point (20, 20)); actionTwo.moveTo (PointOption.point (20, 200)); actionTwo.release (); MultiTouchAction action = new MultiTouchAction (driver); action.add (actionOne); action.add (actionTwo); action.perform ();
  • For Swipe using TouchAction

Example:

TouchAction touchAction = new TouchAction (driver); WebElement factor = (WebElement) driver.findElementById (`` android: id/text2 ''); Point point = element.getCoordinates () .onPage (); Dimension size = element.getSize (); touchAction.press (PointOption.point (point.getX () + 5, point.getY () + 5)) .waitAction (WaitOptions.waitOptions (Duration.ofMillis (200))) .moveTo (PointOption.point (point.getX () + size.getWidth () - 5, point.getY () + size.getHeight () - 5)) .release () .perform ();
  • For Scroll using Javascript Executor

Example:

JavascriptExecutor js = (JavascriptExecutor) driver; HashMap & lt; String, String & gt; scrollObject = new HashMap & lt; String, String & gt; (); scrollObject.put (`` direction '', `` downwards ''); // up, left, right scrollObject.put (`` element '', ((RemoteWebElement) element) .getId ()); js.executeScript (`` mobile: scroll '', scrollObject);
  • For Scrolling element into view by

Example:

driver.findElementByAndroidUIAutomator (`` new UiScrollable (new UiSelector ()) .scrollIntoView (new UiSelector () .text (\ '' Views\ '')); '');
  • For direct Screenshot
((TakesScreenshot) driver) .getScreenshotAs (OutputType.FILE); // BYTES, BASE64 – returns File, byte [] or String (base64 encoded PNG)
  • For update Device Settings
driver.setSetting (Setting.KEYBOARD_AUTOCORRECTION, false); driver.getSettings (); // returns Map & lt; String, Object & gt;
  • For Screen Recording
driver.startRecordingScreen (); driver.stopRecordingScreen();

5. Execute Methods for Extended Functionality

Some advanced Appium methods go beyond standard WebDriver bidding. These are enforce applyExecute Methods, allowing you to trigger mobile-specific actions like unlocking a device, feign a fingerprint scan, or toggling web settings.

These extended Appium methods work through the execute bid, get them compatible with any Appium or Selenium node.

Example:

driver.execute ('mobile: unlock ', [{unlockType: 'pin ', unlockKey: '1234 '}]);

Use Execute Methods when you need advanced control over mobile behavior not covered by default WebDriver APIs.

6. Advanced Commands & # 8211; iOS

Platform-specific commands exclusive to iOS devices, including manage biometric prompting, establish Safari, or interacting with system alarm, helpful for full iOS mechanization coverage.

  • For shaking device
driver.shake ();
  • For adding photos
driver.pushFile (`` img.jpg '', new File (`` path to img.jpg ''));
  • For mail phonation bidding to SIRI

Example:

JavascriptExecutor js = (JavascriptExecutor) driver; Map & lt; String, Object & gt; args = new HashMap & lt; & gt; (); args.put (`` schoolbook '', `` Hey Siri, what 's happening? ``); driver.executeScript (`` mobile: siriCommand '', args);
  • For performing Touch ID in iOS Simulator
driver.performTouchID (true); // Simulates a correct touch ID driver.performTouchID (false); // Simulates a failed touch ID
  • For simulate ironware key

Example:

JavascriptExecutor js = (JavascriptExecutor) driver; Map & lt; String, Object & gt; args = new HashMap & lt; & gt; (); args.put (`` gens '', `` home ''); // volumeup; volumedown driver.executeScript (`` mobile: pressButton '', args);

7. Advanced Commands & # 8211; Android

Advanced bid in Android testing provide greater control over device demeanour, let testers to simulate real-world weather and validate app responses.

Below are key Appium commands for wangle device province, injecting file, simulating hardware key, and retrieving execution data:

  • For lay Battery Percentage
driver.setPowerCapacity (100);;
  • For limit the state of the battery charger to connected or not
driver.setPowerAC (PowerACState.ON); driver.setPowerAC (PowerACState.OFF);
  • For adding photo
driver.pushFile (`` /Pictures/img.jpg '', new File (`` itinerary to img.jpg ''));
  • For simulating ironware key
driver.pressKey (new KeyEvent () .withKey (AndroidKey.HOME)); driver.longPressKey (new KeyEvent () .withKey (AndroidKey.POWER));
  • For have execution data
driver.getPerformanceData (`` my.app.package '', `` cpuinfo '', 6); // returns List & lt; List & lt; Object & gt; & gt;

8. App Management & # 8211; iOS

Appium also allow you install, uninstall, and readjust apps directly on iOS devices through mechanisation, saving time during repeated testing cycles.

  • For installing an app

Example:

args.put (`` app '', `` path/to/app.ipa ''); driver.executeScript (`` mobile: installApp '', args);
  • For verifying if the app is installed

Example:

args.put (`` bundleId '', `` com.myapp ''); (boolean) driver.executeScript (`` mobile: isAppInstalled '', args);
  • For launching the app

Example:

args.put (`` bundleId '', `` com.apple.calculator ''); driver.executeScript (`` mobile: launchApp '', args);
  • For switching the app to foreground

Example:

args.put (`` bundleId '', `` com.myapp ''); driver.executeScript (`` mobile: activateApp '', args);
  • For checking current province of the app

Example:

args.put (`` bundleId '', `` com.myapp ''); (ApplicationState) driver.executeScript (`` mobile: queryAppState '', args); // will revert false if app is not running, differently homecoming true
  • For terminating the app

Example:

args.put (`` bundleId '', `` com.myapp ''); (boolean) driver.executeScript (`` mobile: terminateApp '', args); // will return false if app is not running, otherwise return true
  • For removing the app

Example:

args.put (`` bundleId '', `` com.myapp ''); driver.executeScript (`` mobile: removeApp '', args);

9. App Management & # 8211; Android

Commands in this category allow you to install APKs, manage app permit, clear app data, and access Android-specific utilities from within your.

  • For installing an app
driver.installApp (`` path/to/app.apk '');
  • For verifying if the app is installed
driver.isAppInstalled (`` com.example.android.apis ''); // returns bool
  • For launching the app
driver.launchApp ();
  • For starting activity
driver.startActivity (new Activity (`` com.example.android.apis '', '' .ApiDemos ''));
  • For getting current activeness
driver.currentActivity (); // homecoming String
  • For getting current package
driver.getCurrentPackage (); // returns String
  • For switching the app to foreground
driver.runAppInBackground (Duration.ofSeconds (10)); // Runs for 10 seconds
  • For ensure current state of the app
driver.queryAppState (`` com.example.android.apis ''); // returns Application State
  • For getting app strings
driver.getAppStringMap (`` en '', `` path/to/file ''); // returns Map & lt; String, String & gt;
  • For closing the app
driver.closeApp ();
  • For readjust the app
driver.resetApp ();
  • For terminating the app
driver.terminateApp (`` com.example.android.apis ''); // returns bool
  • For removing the app
driver.removeApp (`` com.example.AppName '');

Test on Real Mobile Devices with BrowserStack

Appium is a go-to tool for mobile automation thanks to its cross-platform support and flexibility. However, existent device testing is crucial, as emulator can ’ t replicate real-world conditions like ironware behavior, battery position, or network intermission.

BrowserStack App Automateoffers a powerful program to run Appium tests on thousands of existent iOS and Android devices on their.

Benefits of Testing on Existent Devices with BrowserStack:

  • : Test under real-world scenarios like low battery, incoming calls, network fluctuations, etc.
  • Instant Access to Real Devices: No need to maintain an in-house device lab, access 3500+ real devices instantly.
  • Cross-Platform Support: Run Appium essay on Android and iOS variant across various screen size and manufacturers.
  • : Speed up test cycle with parallel execution across multiple existent devices.
  • Integration: Easily integrate with Jenkins, GitHub Actions, Azure DevOps, and other CI tools.
  • Elaborate Debugging Tools: Access logs, screenshots, video recordings, and network traffic for efficient root reason analysis

Talk to an Expert

Conclusion

Mastering key Appium command is essential for progress efficient and dependable mobile test automation.

With the right commands and real device testing on platforms like BrowserStack, developer can ensure robust app performance across device, platform, and real-world weather.

Appium Useful Resources

Tutorials

Best Practices, Tips, and Tricks

Getting Started with

Differences and Comparisons

Tags
68,000+ Views

# Ask-and-Contributeabout this matter with our Discord community.

Related Guides

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free