PHP client library for Appium
PHP
Latest commit 27c65f9 Dec 22, 2016 @jlipps jlipps committed on GitHub Merge pull request #39 from RobotUnion/master
fixed bug when tap to single coordinates (getting error: 'Multi Point…

README.md

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
  • getDeviceTime
  • 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.