Giter Club home page Giter Club logo

appium-driver-codeception's Introduction

Appium Driver for Codeception

Appium driver for codeception for writing mobile tests.


Build Status downloads MIT License Donate

All Contributors PRs Welcome Code of Conduct Watch on GitHub Star on GitHub Tweet

Requirement

  1. PHP >= 7.0
  2. Appium
  3. Setup Android SDK on Mac
  4. Inspect App with Appium Desktop

Table of Contents

Install

Just add me-io/appium-driver-codeception to your project's composer.json file:

{
    "require": {
        "me-io/appium-driver-codeception": "~1"
    }
}

and then run composer install. This will install codeception appium driver and all it's dependencies. Or run the following command

composer require me-io/appium-driver-codeception

Tests

Now lets run the following command at the root directory of your project:

codecept bootstrap

This command will creates a configuration file for codeception and tests directory and default test suites.

Writing tests for Android

Now, lets create a new configuration file android.suite.yml inside tests directory and put the following contents inside of it.

class_name: AndroidGuy
modules:
  enabled:
    # Enable appium driver
    - \Appium\AppiumDriver 
    -  Asserts
  config:
    # Configuration for appium driver
    \Appium\AppiumDriver:
      host: 0.0.0.0
      port: 4723
      dummyRemote: false
      resetAfterSuite: true
      resetAfterCest: false
      resetAfterTest: false
      resetAfterStep: false
      capabilities:
        platformName: 'Android'
        deviceName: 'Android device'
        automationName: 'Appium'
        appPackage: io.selendroid.testapp
        fullReset: false
        noReset: false
        newCommandTimeout: 7200
        nativeInstrumentsLib: true
        connection_timeout: 500
        request_timeout: 500
        autoAcceptAlerts: true
        appActivity: io.selendroid.testapp.HomeScreenActivity
        skipUnlock: true

Note: deviceName should be set as Android device only for real device. For Android Emulator use the name of the virtual device.

Generating Actor classes

Now we need to generate actor class for the AndroidGuy that we defined in android.suite.yml. To generate the actor class for AndroidGuy run the following command inside your terminal:

codecept build

Your First Android Test

To create your first android test create a new directory android inside tests folder. After creating the android folder create a new file FirstAndroidCest.php and put the following contents inside of it:

class FirstAndroidCest
{
    public function changeLanguage(AndroidGuy $I)
    {
        $I->implicitWait([
            'ms' => 3500,
        ]);
        $text = $I->byId('id_of_button')->getText();
        $I->assertEquals('Hello, World!', $text);
    }
}

Running tests

Run the appium server by running the following command:

appium

After running the appium server now you need to start android emulator and install the application that you want to test. If you don't know how to start the emulator you can follow the following guide Setup Genymotion Android Emulators on Mac OS

Now run the following command inside your terminal to run the tests:

codecept run android FirstAndroidCest.php--steps

Note: While following the steps that are mentioned here if you get codecept command not found error try to run codecept command like this ./vendor/bin/codecept.

Contributors

A huge thanks to all of our contributors:


Mohamed Meabed

๐Ÿ’ป ๐Ÿ“ข

Zeeshan Ahmad

๐Ÿ’ป ๐Ÿ› โš ๏ธ ๐Ÿ“–

License

The code is available under the MIT license.

appium-driver-codeception's People

Contributors

anooptajawal avatar meabed avatar raleerg avatar ziishaned 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.