How to Run Your First Appium Test Script

On This Page What is Appium?Key Features of AppiumMay 04, 2026 · 11 min read · Tool Comparison

How to Run Your First Appium Test Script

Appium is a democratic open-source framework use to automate test for aboriginal, hybrid, and mobile web apps on both Android and iOS. It lets you write tests habituate languages like Java, Python, or JavaScript, and run them on real devices or emulators.

This article explains how Appium works, how to set it up, and how to run Appium Script locally and on BrowserStack.

What is Appium?

is an open-source for applications support by assorted program like iOS, Android, macOS, and Windows. It enables the tester to write test book in different program words such as JavaScript, Java, Ruby, Python, PHP, and C #. It also volunteer wherein a single API can be used for both Android and iOS platforms.

Appium does not transport dependencies on peregrine operating system. It comprises a wrapper of model that translates Selenium Webdriver command into UIAutomation (iOS) or UIAutomator (Android) require depending on the device type. The OS case does not factor in here.

Key Features of Appium

Appium is wide used in mobile automation because it supports real device, multiple speech, and all app types, without need app changes. Below are its well-nigh important capabilities:

  • Cross-Platform Automation:Appium allows you to write one examination script and run it on both Android and iOS platform. This reduces gemination and speeds up test conception for apps that share functionality across platforms.
  • Multi-Language Support:Appium is based on the WebDriver protocol, which means you can write tests in any language that has a Selenium guest library, such as Java, Python, JavaScript, Ruby, or C #. This flexibility helps teams employment in the language they & # 8217; re most comfortable with.
  • No App Recompilation Needed:Unlike some mobile examination tools, Appium do not need you to recompile or qualify your app. This makes it easier to test production bod and trim the risk of introducing test-specific changes.
  • Support for All App Types:Appium supports aboriginal apps (build using Android or iOS SDKs), hybrid apps (web views wrapped in a aboriginal container), and peregrine web apps accessed through browsers like Chrome and Safari.
  • Real Device and Emulator/Simulator Support:Whether you & # 8217; re running tests topically on emulators or on real devices in the cloud, Appium gives you the flexibility to choose the environment that matches your needs.

Read More:

  • CI/CD Integration:Appium fits well into continuous integration workflows. It can be integrated with tools like,,, and others to enable automated prove as constituent of your build grapevine.
  • Active Community and Ecosystem:As an open-source project with a large user base, Appium benefits from regular updates, plugin support, and community-driven sweetening, making it a full-bodied and germinate mechanization answer.

Appium Architecture

Appium follows a client-server architecture built on the WebDriver protocol. It acts as a bridge between the test script and the mobile device (real or practical), enabling platform-independent automation. Here & # 8217; s a breakdown of its nucleus components and how they interact:

1. Appium Client:The client is the test playscript compose in a supported lyric (Java, Python, JavaScript, etc.) using a WebDriver-compatible library. It sends automation commands to the Appium Server.

2. Appium Server:A Node.js-based server that receives requests from the client in the form of JSON over HTTP. It processes these requests and forward them to the relevant mobile mechanization engine depending on the program.

3. Automation Engines:Appium has two engines

  • UIAutomator2/(Android):Executes commands on Android devices.
  • (iOS):Executes dictation on iOS devices.

Read More:

4. Mobile Device (Real or Emulator/Simulator):The device where the actual app is install and tested. The automation locomotive interacts with the OS and app to perform the examination actions.

Also Read:

5. Bootstrap Components (Platform-Specific):Appium habituate internal help apps (like Appium Settings or uiautomator2-server for Android) to ease communicating between the waiter and the mobile OS.

The following stairs explain how Appium procedure and accomplish a test command within its client-server architecture:

  1. Test Command Sent:The Appium node (your trial script) mail a bid, such as tapping a button, using the WebDriver protocol over HTTP.
  2. Server Receives and Routes:The Appium Server receives the bid, parses it, and place the target platform (Android or iOS) based on the desired capabilities.
  3. Forwarded to Automation Engine:The dictation is routed to the appropriate automation engine. UIAutomator2 or Espresso is used for Android, while XCUITest is used for iOS.
  4. Action Executed on Device:The automation engine interacts with the app on the existent gimmick or emulator to perform the specified action.
  5. Response Returned:The result (success, failure, or yield) is sent rearwards from the device through the automation engine and waiter, and eventually returned to the test script.

Prerequisites for Appium Automation

Appium can be installed:

  • using NPM or
  • downloadingAppium Desktop, a graphical, desktop-based boulevard to launch the Appium server.

In this case, let & # 8217; s download using Appium Desktop.

1. Go to release pageand download the late version of Appium, according to your system configuration.

2.Follow the on-screen didactics and instal Appium.

3.Once the apparatus is complete, run the Appium waiter GUI and check for the host and port configuration as shown below:

4.As a next step, go to the Advancedtab and configure the server speech and port as shown in the snapshot below. Now, you can part the server by clicking on theStart Serverbutton shown:

5.Once the Appium server starts, you can see the server status as shown below:

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

6.Now, you can connect your mobile device to the scheme through a USB cable. Open the command prompting and run the command:ADB devicesto ensure the details of the device.

7.You will too need to render your mobile phone ’ s Android variant number in the Appium script.To discovery this, open your mobile phone and go toSetting & gt; About Phone. In the About Phonescreen, you can see the Android version as present below:

How to Run Appium Test Script

Follow these steps to run the Appium Script.

  1. Create a project in Eclipse, add a package and make a family to pen the exam script.
  2. Make sure the library are configured with the Appium dependance.
  3. The code below help you understand how to write Appium code to launch the play store application:
import java.net.MalformedURLException; import java.net.URL; importee org.openqa.selenium.remote.DesiredCapabilities; import io.appium.java_client.AppiumDriver; signification io.appium.java_client.MobileElement; import io.appium.java_client.android.AndroidDriver; public class AppiumTestcase {public static void independent (String [] args) {//Set the Desired Capabilities DesiredCapabilities caps = new DesiredCapabilities (); caps.setCapability (`` deviceName '', `` My Phone ''); caps.setCapability (`` udid '', `` twist id ''); //Give Device ID caps.setCapability (`` platformName '', `` Android ''); caps.setCapability (`` platformVersion '', `` 11.0 ''); caps.setCapability (`` appPackage '', `` com.android.vending ''); caps.setCapability (`` appActivity '', `` com.google.android.finsky.activities.MainActivity ''); caps.setCapability (`` noReset '', `` true ''); //Instantiate Appium Driver try {AppiumDriver driver = new AndroidDriver (new URL (`` http: //0.0.0.0:4723/wd/hub ''), caps);} catch (MalformedURLException e) {System.out.println (e.getMessage ());}}}

This script would launch the Play Store app on your mobile device. The best way to proceed is to run your script and so monitor the Appium Desktop blind.

You will notice that the Appium Desktop screen will start showing some logs. This is how you will know that your Appium test handwriting is running.

Run Appium Test Script on BrowserStack

BrowserStackApp Automateenables you to quiz native and hybrid mobile covering using the Appium mechanization framework on thou of existent Android and iOS devices. It & # 8217; s easy to run Appium tests written in Java on real Android and iOS devices on BrowserStack.

Setup

  • You will need a BrowserStack username and access key. To obtain your access credentials, or. After that, launch.
  • Ensure you have Appium ’ sJava client libraryinstalled. If you do not receive one, please add the Maven dependency below to your task in IDE. In this case, the IDE being apply is Eclipse.
// Maven users can add this dependency to project 's POM & lt; dependency & gt; & lt; groupId & gt; io.appium & lt; /groupId & gt; & lt; artifactId & gt; java-client & lt; /artifactId & gt; & lt; version & gt; 7.0.0 & lt; /version & gt; & lt; /dependency & gt;
  • Ensure that you feature accession to an Android app (.apk or .aab file) or an iOS app (.ipa file)
/ * Note the `` app_url '' value for the sample app. This value uniquely identifies the app on BrowserStack. * / {`` app_url '': '' bs: //c700ce60cf13ae8ed97705a55b8e022f13c5827c ''} / * In your test script, use this `` app_url '' value to specify the application under test using the `` app '' capability. During test execution, the sampling app will automatically be installed and launched on the device being tested. * / caps.setCapability (`` app '', `` bs: //c700ce60cf13ae8ed97705a55b8e022f13c5827c '')
  • If you do not have an application, please use the sample android or iOS app. In this case, let ’ s use an Android covering.
  • As a next stride, configure the code as demonstrate in the screenshot below. In this causa, lets take a realOnePlus 9 device with Android version 11from the drop down as shown below.

Also, copy the codification snippet from the App Automate dashboard to execute the test case.

Talk to an Expert

Execution of Appium Test Script:

The following Java codification prove how to run an Appium test on BrowserStack using the BrowserStack sample Wikipedia Android app. The test is configure to run on a existent OnePlus 9 device scat Android 11. It automates the following scenario:

  1. Launch the app.
  2. Tap the Search Wikipediastimulus field.
  3. Enter the schoolbook & # 8220;BrowserStack“.
  4. Verify that results are retrovert by control that at least oneTextViewis present.
  5. Close the session usingdriver.quit ().

This test script exerciseDesiredCapabilitiesto specify test parameters and initializes anAndroidDriverinstance to interact with the remote BrowserStack Appium server. The script likewise makes use ofWebDriverWaitto deal synchronization.

Note: Replace & # 8220; your_username & # 8221; and & # 8220; your_key & # 8221;with your literal BrowserStack certification.

Once ready, run the test locally using your build puppet (like Maven or Gradle). It will fulfil on a real twist hosted on BrowserStack.

package android; import java.net.URL; import java.util.List; import java.util.function.Function; importee java.net.MalformedURLException; import io.appium.java_client.MobileBy; import io.appium.java_client.android.AndroidDriver; importation io.appium.java_client.android.AndroidElement; signification org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.WebDriver; meaning org.openqa.selenium.remote.DesiredCapabilities; public class BrowserStackSample {public static void main (String [] args) throws MalformedURLException, InterruptedException {DesiredCapabilities caps = new DesiredCapabilities (); // Set your access credentials caps.setCapability (`` browserstack.user '', `` your_username ''); caps.setCapability (`` browserstack.key '', `` your_key ''); // Set URL of the coating under test caps.setCapability (`` app '', `` bs: //c700ce60cf13ae8ed97705a55b8e022f13c5827c ''); // Specify gimmick and os_version for try caps.setCapability (`` device '', `` OnePlus OnePlus 9 ''); caps.setCapability (`` os_version '', `` 11.0 ''); // Set other BrowserStack capabilities caps.setCapability (`` undertaking '', `` First Java Project ''); caps.setCapability (`` build '', `` browserstack-build-1 ''); caps.setCapability (`` name '', `` first_test ''); // Initialize the remote Webdriver utilise BrowserStack remote URL // and desired capabilities defined above AndroidDriver & lt; AndroidElement & gt; driver = new AndroidDriver & lt; AndroidElement & gt; (new URL (`` http: //hub.browserstack.com/wd/hub ''), caps); // Test case for the BrowserStack sample Android app. // If you have uploaded your app, update the test causa here. AndroidElement searchElement = (AndroidElement) new WebDriverWait (driver, 30) .until (ExpectedConditions.elementToBeClickable (MobileBy.AccessibilityId (`` Search Wikipedia ''))); searchElement.click (); AndroidElement insertTextElement = (AndroidElement) new WebDriverWait (driver, 30) .until (ExpectedConditions.elementToBeClickable (MobileBy.id (`` org.wikipedia.alpha: id/search_src_text ''))); insertTextElement.sendKeys (`` BrowserStack ''); Thread.sleep (5000); List & lt; AndroidElement & gt; allProductsName = driver.findElementsByClassName (`` android.widget.TextView ''); assert (allProductsName.size () & gt; 0); // Invoke driver.quit () after the test is done to indicate that the test is finish. driver.quit ();}}

You are now ready to run your maiden Appium exam on BrowserStack. On your local machine, open the terminal/command prompting and navigate to the booklet check your test script. Build and run the examination script simply like any other Java program using your projection ’ s preferred build tools (E.g. Maven, Gradle).

# Using Maven mvn test -P & lt; android-first-test & gt;

After executing the test case you can see the results on the BrowserStack dashboard.

That ’ s how it works.

Read more:

Troubleshooting Errors and Common Problems in Appium Script

Even with a well-configured apparatus, Appium scripts can run into assorted number, ranging from configuration errors to platform-specific bugs. Below are some of the nearly mutual trouble and tips on how to resolve them:

  • Session Not Created Exception:This often occurs due to an incorrect Appium host URL, mismatched desired capacity, or an outdated automation locomotive. Double-check the deviceName, platformVersion, and automationName in your desired capability.
  • App Not Installed:This erroneousness unremarkably means the app path supply is wrong, or the device miss the necessary permissions. Make certain the app file exists, is accessible, and has the correct extension (.apk or .ipa).
  • Element Not Found:Caused when the locator used in the script does not match any UI element. This may be due to dynamic factor, delays in rendering, or incorrect locator strategy. Use Appium Inspector or UIAutomator Viewer/Xcode ’ s Accessibility Inspector to verify locator.
  • Stale Element Reference Error:This happens when the DOM or UI has refreshed after locating an component. Re-locate the factor before interact with it, especially after piloting or reload event.
  • Appium Server Crashes or Freezes:Can be caused by mismatched driver versions, remembering issues, or unsupported configurations. Ensure you ’ re utilise compatible versions of Appium, drivers (UIAutomator2/XCUITest), and platform SDKs.
  • Inconsistent Behavior Across Devices:UI elements may conduct differently on various screen sizes, OS edition, or manufacturers. Use conditional waits and avoid hardcoded postponement. Also, validate functionality on a range of devices during test planning.
  • Port Already in Use Error:If Appium host fails to start, another process may be using the default embrasure (4723). Either halt the conflicting procedure or start Appium on a different embrasure using the& # 8211; port flag.

Conclusion

Appium is a honest choice for automating mobile app testing across platforms. It supports aboriginal, intercrossed, and web apps, works with popular programming languages, and doesn ’ t require change your app. Whether you ’ re testing on Android or iOS, Appium offers the flexibleness to construct robust, maintainable test suites.

To take your Appium test farther, run them on real devices with. You get instant access to a wide range of Android and iOS device, tight debugging through video and logs, and seamless desegregation with your CI line. This helps you get device-specific bug early, improve test coverage, and liberation confidently across real exploiter environment.

Useful Resources for Appium

Tutorials

Best Practices, Tips, and Tricks

Getting Started with

Differences and Comparisons

Tags
74,000+ Views

# Ask-and-Contributeabout this topic 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