# How to setup an Appium Server?

## Introduction

## Appium Setup

Appium desktop has been deprecated due to security issues and is not advised to use on client machines. As an alternative Appium can be used from command line.

- Launch cmd and type `npm i --location=global appium`
- This command will install all the necessary dependencies. Please ignore `npm fund` as it shows which projects require monetary funding.
- Next, install the particular automation driver, i.e., XCUITest for iOS and UIAutomator2 for Android, by typing `appium driver install uiautomator2`.
- To start the Appium server, type `appium --base-path /wd/hub` to avoid issues while connecting with Leapwork.

**Note:** If you encounter an error while installing uiautomator2, follow the steps below.

ERROR: “Encountered an error when installing package: npm command 'install --save-dev --no-progress --no-audit --omit=peer --save-exact --global-style --no-package-lock appium-uiautomator2-driver --json' failed with code EINVAL.”

1. Open command prompt in “Run as Administrator” mode.
2. Open this file in Notepad: `C:\Users\<Username>\AppData\Roaming\npm\node_modules\appium\node_modules\teen_process\build\lib\exec.js`.
3. Change the shell property to “true” from “undefined” and save.

- Go to command prompt and run `appium driver install uiautomator2` again.

## Leapwork + Appium Connection

Post successful startup of the Appium server, client URLs will be provided as output which can be used in Leapwork to establish a connection with Appium.

In Leapwork, go to settings → connections → add.

Upon clicking Test connection, the Appium server will respond with the below message to confirm a successful connection.

**Note:** As a prerequisite, NodeJS and npm should be present on the machine. To verify if npm is installed, open the Command Prompt and type `npm --version`. This command should return the version number of npm installed on your system.

If you have any questions, please reach out to our [Priority Support](mailto:prioritysupport@leapwork.com) team.
