Appium – Command Line
Last Updated :
26 Apr, 2024
When it comes to mobile app testing, flexibility and efficiency are critical. With the help of the well-known open-source automation technology Appium, testers may automate mobile apps on several platforms. Appium’s command line interface (CLI), which lets testers use the terminal or command prompt to interact with Appium, is one of its most potent features. We will examine the features of Appium’s CLI and how you can use it to automate your mobile testing process in this post.
Appium – Command Line
With the Appium CLI (Command-Line Interface) tool, you can communicate with the Appium server and conduct automated tests for mobile apps right from the command line. Without requiring a graphical user interface, you may use the Appium CLI to start the Appium server, install and run apps on mobile devices or emulators, and run test scripts.
Appium CLI Features
- Server Management: You can use the command line to start, stop, and restart the Appium server. Give details about the host, port, and logging level of the server.
- Device Administration: For testing, connect to real devices or emulators. Install, open, and remove applications from emulators or linked devices.
- Automated Testing: Run test scripts directly in a variety of programming languages (such as Java, Python, and JavaScript)
Getting Started with Appium CLI
Before diving into the intricacies of Appium’s CLI, it’s essential to ensure that you have Appium installed on your system. You can install Appium using npm (Node Package Manager) by running the following command: The first step is check whether the Node.js is installed on your system or not .
To check, open the terminal and run the following command:
node --version
If Node.js is installed in your system then it will reutrn the version of node.js, otherwise it will throw an error ‘error is not recognised’. To download Node.js, visit the official https://nodejs.org/en/download
Choose the node installer according to your system. Window users need to check the bit size before downloading. Once download is finished , run and proceed with the installation. Now restart the terminal and check for the version again by running the command -> node –version. It will return the node version. Mac users can use node -v and npm -v commands to verify the installation and the version details.
To install Appium, run the command given below:
npm install -g appium
Once Appium is installed, you can start the Appium server by simply typing appium in your terminal or command prompt.
Starting the Appium Server
With the help of this command, you can connect to your mobile devices for automation by starting the Appium server.
appium
Install Plugins
For install the plugins use the below commands.
appium plugin install relaxed-caps
Start Appium Server with Custom Options
appium --port 4723 --log-level debug
Advanced Usage
This command starts the Appium server and records debug-level logs into the specified file “/path/to/logfile.tx
appium --log /path/to/logfile.txt --log-level debug
If you’re automating web apps on Android, this command sets the path of the ChromeDriver executable. here’s a some of the commonly used Appium command line options
Command |
Description |
appium |
Start the Appium server |
appium -p <port> |
Specify the port on which Appium should listen |
appium -a <address> |
Specify the IP address to which Appium should bind |
appium -bp <bootstrapPort> |
Specify the bootstrap port for communication with Appium |
appium -U <udid> |
Specify the device UDID to connect to |
appium --no-reset |
Do not reset app state between sessions |
appium --session-override |
Override existing sessions during server startup |
appium --log <file> |
Redirect server output to a file |
appium --log-timestamp |
Add timestamps to server log output |
appium --local-timezone |
Use local timezone for timestamps in logs |
appium --log-level <level> |
Specify log level (debug, info, warn, error, silent) |
appium --default-capabilities <json> |
Specify default capabilities as a JSON object |
appium --command-timeout <timeout> |
Specify the command timeout in milliseconds |
appium --relaxed-security |
Enable relaxed security mode (allowing unsigned apps) |
Share your thoughts in the comments
Please Login to comment...