Skip to content

prashant1507/Appium-Automation-Framework

Repository files navigation

Appium Automation Framework

This is a java appium framework which is using testng, maven, extent report, appium, java, etc to achieve different tasks.

Project's Java Docs
Sample Test Report
Sample Test Video
Execution Settings

Project Features

  • Appium server will start and stop automatically with different ports.
  • Each device's capability file will be created automatically.
  • Supports parallel testing (for parallel="tests" in testng.xml).
  • Multiple devices can be attached to machine.
  • Generates report after each run for all test cases with screenshots.
  • Record video for failed test cases.
  • Option to send report to email (Gmail / Outlook).
  • Option to run tests on local or remote.
  • Read data from Properties file, Excel, JSON files.
  • Real time reporting using ELK.
  • Option to run on docker grid, local, or existing appium server.
  • On-demand browser instance creation using Dynamic Selenium Grid 4.
  • Run using JenkinsFile.

Docker Compose File

Project Components

Below are the component details of the framework:

  • Device interaction using

    Appium

  • Test Data

    Supports to read and maintain data from multiple file types like:

    • Properties File
    • Excel File with the help of ApachePOI Jars
    • JSON File
  • Test Scripts

    TestNg is used as a test framework in order to generate test script taking into account the Page Object Model design pattern.

  • Build Tool

    Using maven, project dependencies are managed. Test can be run using pom.xml and testng.xml.

  • Reporting

    Generates html report automatically by using Extent Report 5. By attaching screenshots and execution videos of the failed test cases.
    However, user can set the framework to take screenshots and videos of passed or/and skipped test cases. All reports are generated in reports-test-output folder. Report automatically opens in default browser.
    Note: Exception logs and fail reasons are added to the report as well. All images are in Base64 and videos in mp4.

  • Utilities

    Holds common methods to re-use in order to achieve maximum re-usability.

  • Test Runner

    • Tests can be executed in parallel and in cross browsers by using:
    • Tests can be executed using:
      • real devices
      • remote devices
      • emulators
  • Other Components

    • JavaMail API and JavaBeans(TM) Activation Framework is used to send the test report automatically on email using gmail or outlook. However, user can still decide if report has to be send or not.
      Note: Framework allows passwords in Base64Encode only.
    • All framework settings are done in properties file, making it easy for a non-technical user.
    • User can opt to run the test with their web drivers placed in drivers folder or with WebDriverManager.

Getting Started:

  1. Set all the properties/setting in properties file.
  2. Run pom.xml or testng.xml file.

Settings for Properties file

Path to properties file

  • url of the test environment.
  • environment where the test has to be performed.
  • testername in order to keep track.
  • ip ip where appium is set up.
  • appiumjs path to main.js (e.g., %APPDATA%/npm/node_modules/appium/build/lib/main.js)
  • nodejs path to node executable (e.g., C:/Program Files/nodejs/node.exe)
  • apppackage app package name.
  • appactivity app activity name.
  • appname app name.
  • runmode decides whether to run test cases on existing appium server, local, grid (/ docker-grid). Accepts yes or no.
    • if runmode is yes then user has to provide the remote url in remoteurl.
    • if runmode is local then provide ip, appiumJS, node executable.
  • useelk yes if elk is deployed
    • elksuiteurl if yes provide the url for kibana
  • To delete old report data:
    deleteoldreports - to elect if tester wants to delete old reports. Accepts yes or no.
    numberofdays - if yes than how old the files should be. Value in number of days.
    
  • overridereports to elect if tester want all reports to be merged in one i.e., current reports plus old ones or create new report for each test suite run. Accepts yes or no.
  • Screenshots:
    passedscreenshot - to take screenshot of passed test cases. Accepts yes or no.
    
  • retryfailedtestcasesto re-run fail test cases. Accepts yes or no. Not recommended setting to set it as yes.
  • Email details to send report:
    sendmailafterexecution - to send report. Accepts yes or no.
    sendmailusing - to choose from gmail or outlook.
    emailid - sender's email id.
    emailpassword - sender's password in Base64Encode only.
    receiversemailid - receiver's email id.
    
    Note: In order to use gmail then enable Allow less secure apps
  • Setup real time report using ELK:
    useelk - to enable using real time reporting using ELK. Accepts yes or no.
    elksuiteurl - url of the elastic search data add.
    
    Note: To use ELK, set the schema to have below keys:
    • TestName

    • Status

    • ExecutionTime

      Note: More fields can be added and changes should be done accordingly in ELKUtils.java

How to set up:

Notes:

  1. For Jenkins to support extent reporting (or other CSS, etc. components ) run below in scripts https://jenkisURL/script System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","")
  2. Uses lombok.
  3. Appium server logs will be stored in logs folder with name currentThread.txt if there is an error.
  4. All capabilities file will be stored in capabilities folder with name deviceUDID.json.

References: