# Connect with local mobile

Using QAautoMATER, you can connect to your local devices to run test scripts. There are some prerequisites for running test scripts on local devices.

\
**Prerequisite**: Node.js and JDK should be installed on the system. You can check if they are installed correctly by using the following commands: `node -v` and `java -version`.

if it is not installed then installed from given below link

{% embed url="<https://www.oracle.com/in/java/technologies/downloads/>" %}

{% embed url="<https://nodejs.org/en/download>" %}

1. **Android SDK (for Windows Machine)**

* Visit the official Android Developer website: Android Studio.
* Click on the "Download Android Studio" button.
* Follow the installation instructions for your operating system (Windows, macOS, or Linux).
* During the installation, make sure to select "Android SDK" as one of the components to be installed.

Please Note : Make sure Platform-tool folder is present is in Android Studio folder (C:\Program Files\Android\Android Studio) , if not then download from the <https://developer.android.com/tools/releases/platform-tools> and paste it into Android studio folder

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2FbZeRsMbi5Wm9StESbO6J%2Fimage.png?alt=media&#x26;token=c1b1382b-b1e4-4fc2-b3e3-af5c3248559a" alt=""><figcaption></figcaption></figure>

Please Note : Make sure apksigner.jar file exist under platform-tools folder if not then download from the link <https://drive.google.com/file/d/1b-HxEkw3bsGZ2IMbLjYL62ezkumsWrJK/view?usp=drive_link> and paste it under platform-tools folder

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2FZMS4xW9e123IrsHYKOps%2Fimage.png?alt=media&#x26;token=9031690e-0de1-471f-9ff2-be7a6859e527" alt=""><figcaption></figcaption></figure>

After installing the Android SDK, Create new environment variable ANDROID\_HOME and set path C:\Program Files\Android\Android Studio\platform-tools

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2FC4PRXO5tuSUee4ODm7xj%2Fimage.png?alt=media&#x26;token=ea5846e8-508f-41d1-aae5-403a40c25a69" alt=""><figcaption></figcaption></figure>

**Xcode (iOS device)** - Download and install Xcode from the Mac App Store. Xcode provides the iOS SDK and necessary tools for iOS development and testing

2. **Appium**

&#x20;    For downnloading appium run the following command

&#x20;   `npm i -g appium`

To start Appium after it has been installed, open a terminal window and execute the following command:

**Windows Machine**

```bash
npm install -g appium-uiautomator2-driver
appium driver install uiautomator2
/****** You can also used espresso as a alternate of uiautomator2
npm i appium-espresso-driver
```

**iOS Machine**

```
npm install -g appium-xcuitest-driver
```

3. **localtunnel**

&#x20;     for downloading localtunnel run the following command

&#x20;    npm install -g localtunnel

**Please note**

For connecting a real device, USB debugging should be enabled on the real device

<https://developer.android.com/studio/debug/dev-options>

### Connect your local mobile and Emulator

After completing the setup, please follow the steps given below

**Step 1**&#x20;

Run the  command to retrieve the device ID. Take note of this device ID and add it to the Configuration page under the 'ADD DEVICE (ONLY FOR SERVER & CLIENT EXECUTION)' section.

**Windows**

```
adb devices
```

**iOS**

```
xcrun simctl list devices
instruments -s devices
```

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2Fp0PGsQ96GBj23afwaodo%2Fimage.png?alt=media&#x26;token=4c03c1d7-c558-47c3-bda2-1f8d84db34f8" alt=""><figcaption></figcaption></figure>

&#x20;![](https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2Fec1nxNliWWJYZtg9WD60%2Fimage.png?alt=media\&token=90e0ae27-f7e6-46b9-aa82-67a611f38993)

**Step 2**

Run the command `appium` from the command line; by default, it will open on port 4723.

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2Fb9w7Y9aeHIupeioKTVzw%2Fimage.png?alt=media&#x26;token=bfd16f74-9b21-45e1-a415-c38c01b8f70f" alt=""><figcaption></figcaption></figure>

**Step 3 (Tunnel )**

Open a new command and run `lt --port 4723`. After executing this command, it will expose port 4723 publicly. Note down the URL and add the URL to the 'Host Name (Applicable for Client)' column with 'https,' removing the trailing '/.'"

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2FtDuI7jL3mOdVi8Xylre4%2Fimage.png?alt=media&#x26;token=f3e45a5b-f083-472f-bbdc-f84008b89d9d" alt=""><figcaption></figcaption></figure>

For other public tuunel , you can follow given below link.

{% content-ref url="../web-automation/connect-your-local-browser-using-selenium-grid" %}
[connect-your-local-browser-using-selenium-grid](https://qabunch.gitbook.io/qaautomater/web-automation/connect-your-local-browser-using-selenium-grid)
{% endcontent-ref %}

**Step 4**

Provide the local path of your APK and IPA files in the 'APK/IPA Path (Applicable for Client)' column if required, and then save the information.

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2F4kllVaX1gbraiJkak44X%2Fimage.png?alt=media&#x26;token=9fb7ec7a-6d2f-4fd0-abf4-578eb7ab3a36" alt=""><figcaption></figcaption></figure>

**Step 5**

Open the URL provided by the command lt --port 4723 in your browser.

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2FPZ6dyshhu0Cxefqkgyyn%2Fimage.png?alt=media&#x26;token=66eb3234-88a8-40ab-89f3-4abce10553a3" alt=""><figcaption></figcaption></figure>

**Step 6**

Provide the tunnel password. You can obtain the tunnel password by clicking on the link: <https://loca.lt/mytunnelpassword> and then click the submit button.

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2FHpvZb8qYBh7DkAcl2pkr%2Fimage.png?alt=media&#x26;token=9a096e09-f737-4bf4-ad9e-1450a92d3346" alt=""><figcaption></figcaption></figure>

**Step 7**

Navigate to the Mobile Test Script page, and select the platform and device according to the added device

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2FuAuYWWVZQ1A1QB0IeSGx%2Fimage.png?alt=media&#x26;token=9ed209c2-f12e-4226-8fca-0a06c75f40af" alt=""><figcaption></figcaption></figure>

**Step 8**

Click on the debugger window; the app will launch on the local system.

<figure><img src="https://423756580-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqEc3xHBB1F9T2KOd6mX7%2Fuploads%2FIvWeePxqkG5qP0YFYYAz%2Fimage.png?alt=media&#x26;token=bdb94dc7-6c9b-4baf-8c25-84baff0794d2" alt=""><figcaption></figcaption></figure>
