How to Install Appium Server and Node on Windows through Command Line
February 13th, 2024
Are you ready to dive deeply into the exciting world of mobile application testing with Appium but feeling a tad overwhelmed about where to begin? You’ve hit the jackpot by landing here!
Consider this guide your go-to pal, guiding you through the ins and outs of setting up Appium Server and Node.js on your Windows machine, and guess what? We’re doing it all using the charm of the Command Line.
That’s right—we’re skipping the maze of GUI setups in favor of some good old-fashioned command-line wizardry.
We’re here to simplify the whole process into easy-to-follow steps that even those new to the game can tackle without breaking a sweat.
Whether you’re preparing to put your innovative app through its paces or aiming to make your testing workflow as smooth as silk, getting Appium and Node.js up and running on your system is your starting line.
So, why not pour yourself a cup of your preferred drink, and let’s tackle this setup together, one command at a time? Stick with us, and before you know it, you’ll be all set to dive into your testing quests with gusto!
Let’s understand How the Architecture of Appium Works
Appium is basically an HTTP server. This server is written in Node.js and it helps to create multiple web Driver session against different platforms. This Appium server receives request from java client which listens for commands from Appium Server.
Let’s have a look at Appium in detail with this video representation.
The way of working of Appium server is almost the same as in selenium RC. The way iOS and android interact with server is quite different. In case of Ios, an Appium proxy commands to a UIAutomation Script. This script would be running in MAC environment.
This application in Ios is called Instruments. In case of android almost everything is same where the server proxy commands to a UIAutomator test case. UIAutomator is a native UI Automation framework which supports junit test cases.
Now let us look at the command line way in which you can install Appium Server on your windows machine.
Installing Appium Server and Node on Windows
Mentioned below is a step-by-step guide on how to install Appium Server and Node on a Windows machine using the command line:
Step #1: Install Node.js
Open a command prompt by pressing Win + R, typing cmd, and pressing Enter.
Check if Node.js is already installed by running the following commands:
Node -v npm -v
If Node.js is not installed, download the latest version from the official website and follow the installation instructions.
Step #2: Install Appium Server
Open the command prompt and install Appium globally using npm:
npm install -g appium
Verify the installation by checking the Appium version:
appium -v
Step #3: Install Appium Dependencies for Android
If you plan to automate Android applications, you must install Appium dependencies for Android. Follow these steps:
Install the Android SDK:
Download Android Studio from the official website.
Run the installer and follow the on-screen instructions.
Open Android Studio, go to “Configure” > “SDK Manager,” and install the necessary SDK components.
Set the ANDROID_HOME environment variable:
Open the System Properties window by right-clicking on “This PC” or “Computer” and selecting “Properties.”
Click on “Advanced System settings” > “Environment Variables.”
Add a new system variable named ANDROID_HOME and the path to the Android SDK as the variable value.
Add Android tools to the system PATH:
Edit the Path variable in the System Variables section and add the following paths:
Step #4: Install Appium Dependencies for iOS (Mac only)
If you plan to automate iOS applications, you must install Appium dependencies for iOS. Follow these steps:
Install Xcode from the Mac App Store.
Install Appium dependencies using npm:
npm install -g appium-doctor
Run appium-doctor to check for any missing dependencies:
Follow the instructions provided by Appium-doctor to install any missing dependencies.
Step #5: Start Appium Server
Open a command prompt and start the Appium server:
Appium will start, and you’ll see logs indicating that the server is listening on a specific address and port.
Note: If you encounter any issues related to ports being in use, you can specify a different port using the –port option:
bashCopy code
appium –port 4725
Step 6: Test Appium Installation
After installing Appium successfully, it is time to test the installation by running a simple test script. Create a new file with a .js extension (e.g., test.js) and add the following code:
Replace the placeholder values (YOUR_ANDROID_VERSION, YOUR_DEVICE_NAME, PATH_TO_YOUR_APK, and ID_OR_XPATH_OF_AN_ELEMENT) with appropriate values for your Android device and application.
Run the test script using the following command:
node your_test_script.js
If everything is set up correctly, Appium will launch your application on the specified device, interact with the specified element, and close the session.
Why Appium?
If you are wondering why Appium is a preferred choice for mobile testing, here are some of the common reasons:
Cross-Platform Compatibility: Appium supports Android and iOS, allowing you to write tests for both platforms using a single codebase.
Programming Language Agnostic: You can write Appium tests in multiple programming languages, including Java, Python, C#, and more.
Open Source: Because Appium is open source, a worldwide community of developers is constantly improving it. This ensures that it stays up-to-date with the latest mobile technologies.
No App Modification: Appium tests your app in the same way that users use it, without modifying the app. This provides a more realistic testing environment.
Prerequisites of Installing Appium
Before installing Appium, make sure you have the following prerequisites:
Java Development Kit (JDK): Appium is built on Java, so you must install the JDK on your machine. You can download the latest JDK version from the official Oracle website.
Android Studio: If you plan to automate Android applications, install Android Studio to set up the necessary Android dependencies. Download Android Studio from the official website.
Xcode: For automating iOS applications, you’ll need Xcode. Install it from the Mac App Store if you’re using a Mac.
Node.js: Appium is built on Node.js, so you need to have Node.js installed. Download the latest version from the official Node.js website.
Conclusion
Hence, now you got to know that installation of Appium is damn easy with the command line rather than doing it manually. NPM is a wonderful package installer and makes your task easier. Install it and start the automation. All the best!!
FAQs
Why is Appium important in iOS and Android App testing? Is it because of its architecture?
Appium plays a pivotal role in iOS and Android app testing, primarily due to its unique architecture, which allows for seamless cross-platform testing.
This tool operates on a client-server model, enabling testers to write tests in their preferred language using standard APIs. Its significance lies in the ability to test native, hybrid, and mobile web apps without needing to alter the app code.
By supporting Android and iOS platforms, Appium facilitates a more efficient testing process, reducing the time and resources spent on writing and maintaining separate tests for each platform.
This approach not only enhances productivity but also ensures consistency in testing across different environments.
How Appium Architecture Works?
Test Script Initialization:
The developer writes a test script using their preferred programming language and the corresponding Appium client library.
Appium Server Startup:
The developer starts the Appium Server, specifying the desired capabilities such as the platform (Android or iOS), device details, application path, and other relevant configurations.
Connection Establishment:
The Appium client library in the test script initiates a connection to the Appium Server by providing the server’s address (IP and port) and the desired capabilities for the test session.
WebDriver Commands:
The test script, through the Appium client, sends WebDriver commands to the Appium Server. These commands include actions like tapping on an element, entering text, or navigating between screens.
Translation and Execution:
The Appium Server translates the WebDriver commands into corresponding actions supported by the mobile platform. For example, a WebDriver “click” command might translate to a tap on the screen.
Interaction with Mobile Device:
The translated commands are then executed on the mobile device, interacting with the application just as a user would. This interaction includes gestures, input, and navigation.
Response Handling:
The Appium Server captures the responses from the mobile device and communicates them back to the Appium client. These responses may include success or failure indicators, as well as any relevant data.
Test Script Completion:
The test script processes the responses received from the Appium Server, making decisions based on the success or failure of each command. The script may also include assertions to verify the expected behavior of the application.
Session Closure:
Once the test script completes its execution, the Appium Server closes the WebDriver session, releasing the resources associated with the test session.
How To Start the Appium server in CMD?
To start the Appium server via the Command Prompt (CMD) on Windows or Terminal on macOS/Linux, you first need to have Appium installed. If you haven’t installed Appium, you can install it using Node.js’s package manager (npm) with the following command:
npm install -g appium
Once Appium is installed, you can start the server by opening CMD or Terminal and running the following command:
appium
This command starts the Appium server with the default settings, typically listening on port 4723. If you want to specify a different port or customize other settings, you can use various flags. For example, to start the Appium server on port 5000, you can use:
appium -p 5000
For more advanced configurations and options, you can refer to the official Appium documentation or use the appium --help command to see a list of all available command-line options.
Is node js mandatory for Appium?
Yes, Node.js is mandatory for Appium. Appium is built on the Node.js platform and uses JavaScript for its execution. The installation of Appium itself is typically managed through npm (Node Package Manager), which is a part of Node.js.
Therefore, having Node.js installed on your system is a prerequisite for installing and running Appium for automated mobile application testing.
How to install Appium using npm on Windows?
To install Appium on Windows using npm, follow these steps:
Open Command Prompt as an administrator.
Ensure Node.js is installed by running node -v. If not installed, download and install it from nodejs.org.
Install Appium by executing npm install -g appium.
Verify the installation with appium -v.
This installs Appium globally on your Windows system, making it accessible from any command prompt.
How do I run an Appium server?
To run an Appium server, follow these simple steps:
Open your command prompt or terminal.
Type appium and press Enter.
This command starts the Appium server with default settings. You can customize its behavior using various flags (e.g., appium --port 4723 to specify a different port).
How to install node on Windows Terminal?
To install Node.js on Windows using Windows Terminal, follow these steps:
Visit the official Node.js website (nodejs.org) to download the Windows installer.
Choose the version you need (LTS for stability or Current for the latest features).
Once downloaded, run the installer (.msi file) and follow the installation prompts. Ensure to select the option to add Node.js to the PATH if asked.
After installation, open Windows Terminal.
Verify the installation by running node -v and npm -v to check Node.js and npm versions, respectively.
This process installs Node.js and npm (Node Package Manager), enabling you to run Node.js applications and install packages globally.
How to install node test?
To verify that Node.js is installed on your system:
Open your terminal or command prompt.
Type node -v and press Enter. This command will show the installed Node.js version, indicating that Node.js is installed.
You can also check npm (Node Package Manager), which comes with Node.js, by typing npm -v and press Enter. This will display the installed npm version.
Installing a Package Named “test”
If there’s a specific npm package you’re looking to install named “test” (this is a hypothetical scenario as there might not be a package with this exact name meant for general use), you can install it using npm with the following command:
npm install test
For installing any package for development purposes and saving it to your project’s package.json file, you can use:
npm install test –save-dev
Replace “test” with the package name you intend to install. If you’re experimenting with or learning about npm packages, you can replace “test” with a real package name, like “express” for a web server framework or “jest” for testing.
Note
If you’re new to Node.js and npm, it’s worth mentioning that “test” is often used in documentation and tutorials as a placeholder for the actual package name you wish to install or the command to run tests defined in a package.json file. To run tests defined in your package’s package.json, you would use:
npm test
This command runs the test script specified in the “scripts” section of package.json.