Coder Social home page Coder Social logo

basic_appium_framework's Introduction

basic_appium_framework

Summary

  • A basic Appium framework for an Android app using Appium, Java, Gradle, the PageObject pattern, PageFactory, TestNG, Hamcrest

App Under Test

  • We are using the ApiDemos-debug.apk sample app included on Appium's GitHub repository.

ApiDemos-debug Home Page

alt text

The Test Outline

  • Appium, using the Desired Capabilities will install and launch the app @BeforeSuite.
  • We will wait for the header to appear on the HomeScreen page.
  • Select the “Text” button then Wait for the header on the InnerApiDemos page to appear.
  • Select “LogTextBox”. Wait for the header on the LogTextBox page to appear.
  • Select the ADD button. In the panel below the ADD button, the text "This is a test" should display in the panel.
  • Assert that the words “This is a test” appears in the panel.
  • After the test is run, we will tear down the driver.

Pre-requisites

  • Appium must be running on your local computer, such as with Appium Desktop
  • An emulator must be connected via adb, the Android Debug Bridge, called emulator-5554

Directory Structure:

src 
-> test
   -> java
      --> pages
         HomeScreenPage.java
	 InnerApiDemosPage.java
	 LogTextBoxPage.java
      --> utils
         TestUtils.java
	 
	SmokeTest.java 
ApiDemos-debug.apk
build.gradle

The Smoketest

    @Test
    public void test_login() throws Exception {
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

        homeScreen.verifyHeader();
        homeScreen.selectTextButton();

        innerApiDemoScreen.verifyHeader();
        innerApiDemoScreen.selectLogTextBoxButton();

        logTextBoxPage.verifyHeader();
        logTextBoxPage.selectAddButton();

        String expectedPanelText = "This is a test";
        String actualPanelText = logTextBoxPage.getPanelText();

        System.out.println("Checking panel text...");

        TestUtils.outputIfMatchPassOrFail(expectedPanelText, actualPanelText);
        assertThat(actualPanelText,containsString(expectedPanelText));
    }

Output Rendered After Running Automated Test

HOME_SCREEN_PAGE: Verifying Header appears.
HOME_SCREEN_PAGE: Selecting [TEXT] button.

INNER_API_DEMOS_PAGE: Verifying Header appears.
INNER_API_DEMOS_PAGE: Selecting [LogTextBox] button.

LOG_TEXT_BOX_PAGE: Verifying Header appears.
LOG_TEXT_BOX_PAGE: Selecting [ADD] button.

Checking panel text...
Verifying Expected Value Matches Actual Value:
	* Expected Value: This is a test
	* Actual Value: This is a test

===> (PASS)

Tearing Down Driver.

Setup and Code Walkthrough on Building a Basic Appium Framework

Future plans

Other Appium frameworks, modeled on this code, will include:

  • Appium will be started and stopped programatically.
  • We will use abstract classes BaseTest and BasePage, refactoring common elements out. Tests and Pages will be extensions of these BaseTests and BasePages.
  • iPads, iPhones, both physical devices and emulators
  • Multiple mobile devices running tests simulatneously and in parrallel
  • Better logs

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.