Framework for Mobile test automation using Appium with Java - BDD

Overview

appium-mobile-automation-framework-bdd

Mobile automation framework using appium - BDD

🚀 Quick Start - Appium set up on Windows (Android):

  1. Install Java JDK8 and IntelliJ IDEA
  2. Install NodeJS
  3. Install Android studio
  4. Install Appium Server using npm (CLI) command npm install -g appium. Appium server version 1.22.3
Command to check the installed appium version: `appium --version`
  1. Add below Android SDK path in the environment variable
    - ANDROID_HOME = <path to Sdk folder>
    - %ANDROID_HOME%\tools
    - %ANDROID_HOME%\tools\bin
    - %ANDROID_HOME%\platform-tools
  1. Install Appium desktop
  2. Install Appium Inspector

🚀 Quick Start - Appium set up on MAC (Android):

  1. Install Homebrew
  2. Install NodeJS
  3. Install Java JDK8 and IntelliJ IDEA
  4. Install Appium server using npm (CLI) or Appium desktop client
  5. Install Android studio
  6. Install Appium Inspector
  7. Set JAVA_HOME and ANDROID_HOME environment variables

📌 Appium Doctor to verify the installations

  1. Install appium-doctor using command npm install -g appium-doctor
  2. To view the list of available options appium-doctor --help
To check Android set up `appium-doctor --android`
To check ios set up `appium-doctor --ios`

📌 Creating Android Virtual Device (Emulator) from Android Studio:

  1. Open Android Studio.
  2. Click on Tools -> AVD Manager -> Create Virtual Device -> Select the device and OS version -> Finish.
  3. Once Virtual device is created, click on Launch this AVD in the emulator.
  4. Command to view the list of devices attached adb devices

📌 Android Real Device Set up:

  1. Connect Android real device to the machine(Desktop/Laptop)
  2. Turn on the developer options in android mobile
  3. Enable USB debugging
  4. Run command adb devices in cmd prompt to check whether the device is recognised

📌 Mirror android/ios device to your desktop

  1. Download Vysor

📌 Start Android Emulator from Command line

  1. Open command prompt, go to <sdk emulator path>
Command to stard AVD: `emulator -avd <avd_name>`
Command to stop/kill AVD: `adb -e emu kill`

📌 Pushing the App (.apk file) to Android Emulator:

  1. Copy the .apk file and paste it in the path - <path to sdk platform-tools>
  2. Open the cmd terminal from the directory where APK file is placed and enter command adb install <apk filename>

📌 Android - Finding appPackage and appActivity:

If the app is already installed on your device then we can make use of appPackage and appActivity to launch the app

Option 1 :

  1. Open the app on the device, for which appPackage and appActivity is required.
  2. Open powershell and enter command adb shell dumpsys window | grep -E 'mCurrentFocus|mFocusedApp' NOTE: This command may not work for newer Android OS (10 or 11). In that case, use command: adb shell "dumpsys activity activities | grep mResumedActivity"

Option 2 : Install APK info app to retrieve appPackage and appActivity for the app installed in your device

?? Inspecting Elements

uiautomatorviewer

  1. Go to the path - <path to sdk folder>\tools\bin\
  2. click on uiautomatorviewer
  3. On the UI Automator Viewer, click on Device Screenshot (uiautomator dump). Ui automator will capture the screenshot of current open screen in the device.

UiAutomatorViewer

Appium Inspector

  1. Start the Appium Server and connect with Real device/Emulator.
  2. Open Appium Inspector app and provide the appium server details and Desired Capabilities.

Appium Inspector

  1. Click on Start session which will start the appium inspector with layout shown below.

Appium

📌 Inspecting Element for mobile web browser

Type url `chrome://inspect/#devices` in the desktop chrome browser and start inspecting element

Capture

📌 Launching Android Emulator Automatically

Add below lines in the Desired capabilities

capability.setCapability(AndroidMobileCapabilityType.AVD, "Pixel_3a");
capability.setCapability(AndroidMobileCapabilityType.AVD_LAUNCH_TIMEOUT, "180000");

📌 Auto Discovery of compatible ChromeDriver

Start appium server using command appium --allow-insecure chromedriver_autodownload

📌 Auto download of compatible ChromeDriver programmatically

Add below line in the AppiumServiceBuilder

AppiumServiceBuilder builder = new AppiumServiceBuilder();
builder.withArgument(GeneralServerFlag.ALLOW_INSECURE, "chromedriver_autodownload");

📌 Start Appium server programmatically

Use AppiumServiceBuilder and AppiumDriverLocalService to start the server programmatically Set environment variable APPIUM_HOME = <path to npm folder>\node_modules\appium\build\lib where main.js file is present

📌 Running tests through Test Runner (JUnit)

👉 Run RunCucumberTest in the path appium-mobile-automation-framework-bdd\src\test\java\org\example\runner\RunCucumberTest.java

📌 Running tests in parallel on multiple devices through Maven CLI

👉 Run test using following command

mvn clean test -DplatformName=<platform name> -DdeviceName=<device name> -Dudid=<udid> -DsystemPort=<system port number> -DchromedriverPort=<chromedriver port>

Example:
mvn clean test -DplatformName=android -DdeviceName=Pixel_4 -Dudid=emulator-5554 -DsystemPort=7070 -DchromedriverPort=7071

📌 Config Json for updating DesiredCapabilities

Capture

You might also like...

A sample repo to help you emulate network control using CDP in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to emulate network control using CDP in Java-TestNG automation test on LambdaTest Environment Setup Global Dependencies Install Maven Or Install M

Oct 23, 2022

A sample repo to help you set device mode using CDP in Java-TestNG automation test on LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

How to set device mode using CDP in Java-TestNG automation test on LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven wit

Jul 13, 2022

A sample repo to help you handle basic auth for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

A sample repo to help you handle basic auth for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to handle basic auth for automation test in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Windows - htt

Jul 13, 2022

A sample repo to help you run automation test in incognito mode in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

A sample repo to help you run automation test in incognito mode in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to run automation test in incognito mode in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Windows - htt

Jul 13, 2022

A sample repo to help you handle cookies for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

A sample repo to help you handle cookies for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to handle cookies for automation test in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Windows - https:

Jul 13, 2022

A sample repo to help you set geolocation for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

A sample repo to help you set geolocation for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to set geolocation for automation test in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Windows - https

Jul 13, 2022

A sample repo to help you capture JavaScript exception for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

A sample repo to help you capture JavaScript exception for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to capture JavaScript exception for automation test in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Wi

Jul 13, 2022

A sample repo to help you find an element by text for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

A sample repo to help you find an element by text for automation test in Java-selenium on LambdaTest. Run your Java Selenium tests on LambdaTest platform.

How to find an element by text for automation test in Java-selenium on LambdaTest Prerequisites Install and set environment variable for java. Windows

Jul 13, 2022
Owner
Thangaraj
SDET
Thangaraj
BDD framework for automation using Selenium Cucumber and TestNg

Selenium Framework with Cucumber BDD framework for automation using Selenium Cucumber and TestNg The framework has following features Modular Design M

null 3 Jan 20, 2022
Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.

That feeling you get when you know you can trust your tests Serenity BDD is a library designed to make writing automated acceptance tests easier, and

Serenity BDD 654 Dec 28, 2022
🤖 Unleash the full power of test.ai into your Java Appium tests

The test.ai Appium SDK is a simple library that makes it easy to write robust cross-platform mobile application tests backed by computer vision and ar

test.ai 9 Jun 4, 2022
A sample repo to help you test in Java-TestNG-Appium for LambdaTest. Run Selenium tests with TestNG on LambdaTest platform.

Sample automation test in Java-TestNG-Appium for LambdaTest Environment Setup Global Dependencies Install Maven Or Install Maven with Homebrew (Easier

null 13 Jul 13, 2022
A powerful open source test automation platform for Web Apps, Mobile Apps, and APIs

A powerful open source test automation platform for Web Apps, Mobile Apps, and APIs. Build stable and reliable end-to-end tests @ DevOps speed.

Testsigma Technologies Inc 466 Dec 31, 2022
A BDD-style test runner for Java 8. Inspired by Jasmine, RSpec, and Cucumber.

Spectrum A colorful BDD-style test runner for Java Spectrum is inspired by the behavior-driven testing frameworks Jasmine and RSpec, bringing their ex

Greg Haskins 143 Nov 22, 2022
Master Selenium Framework BDD

Automation Testing | Web | API | Atomic Tests | Cucumber | Java | OOPS | Selenium WebDriver | TestNG | Maven | Cucumber Reports | Java mail API | Design Patterns (Page Object Model, Singleton) | Jenkins

Rajat Verma 38 Dec 14, 2022
🎁 A demo/tutorial for java-appium-sdk

test-ai-appium-demo Welcome to the test.ai Appium Java demo! This repository contains a pre-configured project and basic tutorial, so you can hit the

test.ai 5 Jun 14, 2022
Ready-to-use UI Test Automation Architecture using Java and Selenium WebDriver.

Selenium Test Automation Boilerplate Ready-to-use UI Test Automation Architecture using Java and Selenium WebDriver. Languages and Frameworks The proj

Tahanima Chowdhury 133 Dec 26, 2022
Restful-booker API test automation project using Java and REST Assured.

Restful-booker API Test Automation Restful-booker API is an API playground created by Mark Winteringham for those wanting to learn more about API test

Tahanima Chowdhury 7 Aug 14, 2022