Coder Social home page Coder Social logo

php-client's Introduction

Appium PHP Client

An extension library to add Selenium 3 features to Appium.

The library is installable using the Composer dependency manager. Just add "appium/appium-php": "dev-master" (or any other branch/tag you might like) to your composer.json file's requires, and the repository on GitHub to the repositories:

{
    "name": "username/my-php-project",
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/appium/php-client"
        }
    ],
    "require": {
        "appium/php-client": "dev-master"
    }
}

Then install the dependencies and run your tests:

composer install
vendor/phpunit/phpunit/phpunit <mytest.php>

Usage and changes

There are a number of methods added to Selenium 3/Appium 1. The central change is in the test case that serves as the base of your tests, and the elements with which you interact. Both are subclasses of the PHPUnit Selenium classes. Your tests should be subclasses of PHPUnit_Extensions_AppiumTestCase, and all elements that get returned will be of the class PHPUnit_Extensions_AppiumTestCase_Element.

require_once('PHPUnit/Extensions/AppiumTestCase.php');
require_once('PHPUnit/Extensions/AppiumTestCase/Element.php');

class MySuperTests extends PHPUnit_Extensions_AppiumTestCase
{
    public static $browsers = array(
        array(
            'local' => true,
            'port' => 4723,
            'browserName' => '',
            'desiredCapabilities' => array(
                'app' => APP_PATH
            )
        )
    );

    public function testStuff()
    {
        $element = $this->byAccessibilityId('Element on screen');

        $this->assertInstanceOf('PHPUnit_Extensions_AppiumTestCase_Element', $element);
    }
}

Methods added

Methods in PHPUnit_Extensions_AppiumTestCase

  • byIOSUIAutomation
  • byAndroidUIAutomator
  • byAccessibilityId
  • keyEvent
  • pullFile
  • pushFile
  • backgroundApp
  • isAppInstalled
  • installApp
  • removeApp
  • launchApp
  • closeApp
  • endTestCoverage
  • lock
  • shake
  • hideKeyboard
  • initiateTouchAction
  • initiateMultiAction
  • scroll
  • dragAndDrop
  • swipe
  • tap
  • pinch
  • zoom
  • startActivity
  • getSettings
  • setSettings

Methods in PHPUnit_Extensions_AppiumTestCase_Element

  • byIOSUIAutomation
  • byAndroidUIAutomator
  • byAccessibilityId
  • setImmediateValue

Methods for Touch Actions and Multi Gesture Touch Actions

Appium 1.0 allows for much more complex ways of interacting with your app through Touch Actions and Multi Gesture Touch Actions. The PHPUnit_Extensions_AppiumTestCase_TouchAction class allows for the following events:

  • tap
  • press
  • longPress
  • moveTo
  • wait
  • release

All of these except tap and release can be chained together to create arbitrarily complex actions. Instances of the PHPUnit_Extensions_AppiumTestCase_TouchAction class are obtained through the Test Class's initiateTouchAction method, and dispatched through the perform method.

The Multi Gesture Touch Action API allows for adding an arbitrary number of Touch Actions to be run in parallel on the device. Individual actions created as above are added to the multi action object (an instance of PHPUnit_Extensions_AppiumTestCase_MultiAction obtained from the Test Class's initiateMultiAction method) through the add method, and the whole thing is dispatched using perform.

php-client's People

Contributors

imurchie avatar jlipps avatar jonahss avatar

Watchers

James Cloos avatar Jayachandra 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.