GithubHelp home page GithubHelp logo

budtmo / coteafs-appium Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wasiqb/coteafs-appium

0.0 2.0 0.0 57.34 MB

Wrapper Appium Framework which supports Automation of Mobile and Tablet apps for Android and iOS Real Devices / Emulators.

Home Page: https://wasiqb.github.io/coteafs/appium/

License: Apache License 2.0

Java 100.00%

coteafs-appium's Introduction

Wrapper Appium Framework which supports Automation of Mobile and Tablet apps for Android and iOS Real Devices / Emulators.

Note: Documentation site is under updation. Although some part of documentation is ready. Checkout this space to know when the documentation is ready.

Open Source Love CircleCI Average time to resolve an issue Bugs Test Coverage Quality Gate Maintainability Reliability Security Vulnurability Duplicate Code Maven Central Github Releases

๐Ÿš€ Quick Start

  • The documentations of coteafs-appium includes all the information you need to get started including setup, usage, advantages, sample test.
  • To know what changes are Released, check out the change log for complete list of changes.
  • Want to know when our next feature or fix release is going to happen? Watch out our planned milestones.

First step in writing tests using coteafs-appium framework is defining a Yaml config file in the src/test/resources folder.

(For more details, check the link above.)

Sample file is shown below.

servers:
  android:
    host: 127.0.0.1
    port: 4723
    external: true
    arguments:
      log_level: DEBUG
      log_time_stamp: true
      local_time_zone: true
      session_override: true
      android:
        suppress_adb_kill_server: true
devices:
  test:
    platform_type: ANDROID
    device_name: MI Redmi Note 4
    device_version: 7.0
    app_type: HYBRID
    device_type: REAL
    automation_name: APPIUM
    app_location: apps/android/VodQA.apk
    session_timeout: 120000
    playback:
      delay_before_swipe: 200
      delay_after_swipe: 100
      delay_before_tap: 0
      delay_after_tap: 0

By using Action classes for each Activity, the flow specific for that activity can be modularized and tests looks much clean and readable. See the sample test below.

import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;

import com.github.wasiqb.coteafs.appium.android.vodqa.actions.LoginActivityAction;
import com.github.wasiqb.coteafs.appium.service.AppiumServer;

public class SampleTest {
  protected AndroidDevice androidDevice;
  private AppiumServer androidServer;

  @BeforeClass
  public void setupTestSuite () {
    this.androidServer = new AppiumServer ("android");  // Here the parameter refers to the key in server block in config file.
    this.androidServer.start ();

    this.androidDevice = new AndroidDevice (this.androidServer, "test");  // Here the param refers to the key in devices block in config file.
    this.androidDevice.start ();
  }

  @AfterClass (alwaysRun = true)
  public void tearDownTestSuite () {
    this.androidDevice.stop ();
    this.androidServer.stop ();
  }

  @Test
  public void login () {
    final LoginActivityAction login = new LoginActivityAction (this.androidDevice);
    login.addInputValue ("UserName", "admin")
      .addInputValue ("Password", "admin")
      .perform ();
  }
}

New class needs to be created for each Activity. There's an abstract activity class for each type of device. Here prepare method needs to be implemented with all the elements available on that Activity.

See the below sample for an Android activity with comments for better understanding.

import org.openqa.selenium.By;

import com.github.wasiqb.coteafs.appium.android.AndroidDevice;
import com.github.wasiqb.coteafs.appium.device.DeviceElement;

public class LoginActivity extends AndroidActivity {
  public LoginActivity (final AndroidDevice device) {
    super (device);
  }

  @Override
  protected DeviceElement prepare () {
    final DeviceElement main = DeviceElement.create ("Main")
      .forAndroid (By.id ("android:id/content"));
    DeviceElement.create ("Back")
      .parent (main)
      .forAndroid (By.xpath ("//android.widget.TextView[@text=\"Back\"]"))
      // We can set multiple locators for different Automation names.
      .forAndroid (AutomationType.UIAUTOMATOR2, MobileBy.AndroidUIAutomator ("new UiSelector ().text (\"Back\");"));
    DeviceElement.create ("UserName")
      .forAndroid (MobileBy.AccessibilityId ("username"))
      .parent (main);
    DeviceElement.create ("Password")
      .forAndroid (MobileBy.AccessibilityId ("password"))
      .parent (main);
    DeviceElement.create ("Login")
      .index (1)    // Index of element when multiple elements for same locator exists.
      .waitStrategy (WaitStrategy.VISIBLE)  // Wait strategy to be used while finding the element.
      .forAndroid (MobileBy.AccessibilityId ("login"))     // Locator used to find the element.
      .parent (main);    // Parent of current element.
    return main;
  }
}

There is abstract action class provided by framework where Activity specific flow is implemented in perform method. See the sample Activity action class below.

import com.github.wasiqb.coteafs.appium.android.AndroidActivityActions;
import com.github.wasiqb.coteafs.appium.android.AndroidDevice;
import com.github.wasiqb.coteafs.appium.android.vodqa.activities.LoginActivity;

public class LoginActivityAction extends AndroidActivityActions {
  public LoginActivityAction (final AndroidDevice device) {
    super (device);
  }

  @Override
  public void perform () {
    final LoginActivity login = new LoginActivity (getDevice ());
    login.onElement ("UserName")
      .enterText (value ("UserName"));
    login.onElement ("Password")
      .enterText (value ("Password"));
    login.onDevice ()
      .hideKeyboard ();
    login.onElement ("Login")
      .tap ();
  }
}

๐Ÿ‘ Liked the framework until now?

Add dependency to your projects POM.

<dependency>
  <groupId>com.github.wasiqb.coteafs</groupId>
  <artifactId>appium</artifactId>
  <version>3.0.0</version>
</dependency>

In order to use a framework, it's important to know it's advantages. Let's see what are the key features of this framework:

  • ๐Ÿ“ฑ Supports Android and iOS Real Devices and Emulators.
  • ๐Ÿ’ป Able to start and stop server on run-time and also can connect to already running server.
  • ๐Ÿ““ Enforces Page object model style of coding.
  • ๐ŸŒŒ Allows parallel and sequential execution of tests.
  • ๐Ÿ”จ All capabilities, playback and delay settings are configurable through config file.
  • โ˜๏ธ Supports execution of tests on any Cloud solution like BrowserStack, SauceLabs, TestingBot, etc.
  • ๐Ÿ“น Supports video recording of tests on Android and iOS.
  • ๐Ÿ“ท Supports capturing screenshots for Android and iOS.
  • ๐Ÿ“‹ Supports reading Clipboard from devices.
  • ๐Ÿ“” Supports logging of all events occurred during test execution.
  • โŒ Provides pre-defined errors which wraps the Appium exceptions in a meaningful way.
  • โœ… Provides inbuilt assertions to verify the device elements.
  • โ™จ๏ธ Supports any Testing frameworks like TestNG, JUnit or Cucumber.

โ“ What to do when you need help?

  • Directly chat with me on my site and I'll revert to you as soon as possible.
  • Discuss your queries by writing to us on our mailing list
  • If you find any issue which is bottleneck for you, search the issue tracker to see if it is already raised.
  • If not raised, then you can create a new issue with required details as mentioned in the issue template.

โญ What you do if you like the project?

  • Spread the word with your network.
  • Star the project to make the project popular.
  • Stay updated with the project progress by Watching it.
  • Contribute to fix open issues, documentations or add new features. To know more, see our contributing page.

โœ”๏ธ Contributors

๐Ÿ’ Thanks for the support.

For allowing us to run our unit tests on different platforms.

๐ŸŽซ Versioning ideology

ยฉ๏ธ - Wasiq Bhamla

coteafs-appium's People

Contributors

mfaisalkhatri avatar wasiqb avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.