PHP code example of walterwhites / appium-module

1. Go to this page and download the library: Download walterwhites/appium-module library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

walterwhites / appium-module example snippets


/**
 * @group register
 * Tests the sign up
 * @param User $params
 */
public function registerByEmail(User $params)
{
    $this->test->clickOnButton('SIGN UP', 400);
    $this->test->clickOnButton('SIGN UP WITH EMAIL', 400);
    $this->test->setText('First name', $params->firstName);
    $this->test->setText('Last name', $params->lastName);
    $this->test->setText('Email address', $params->email);
    $this->test->hideKeyboard();
    sleep(2);
    $this->test->touchPositionedButon(2);
    sleep(2);
    $this->test->touchPositionedButon(3);
    $this->test->clickOnButton('SIGN UP', 300);
}

protected $locatorStrategy = ILocatorStrategy::class_chain;
protected $classChainSearch = IClassChainSearch::label;
use Button;
use TextField;

public function setLocatorStrategy($locatorStrategy)
{
    switch ($locatorStrategy) {
        case ILocatorStrategy::class_chain:
            $this->locatorStrategy = ILocatorStrategy::class_chain;
            break;
        case ILocatorStrategy::predicate_string:
            $this->locatorStrategy = ILocatorStrategy::predicate_string;
            break;
        case ILocatorStrategy::accessibility_id:
            $this->locatorStrategy = ILocatorStrategy::accessibility_id;
            break;
    }
}

public function setClassChainSearch($classChainSearch)
{
    switch ($classChainSearch) {
        case IClassChainSearch::label:
            $this->locatorStrategy = IClassChainSearch::label;
            break;
        case IClassChainSearch::name:
            $this->locatorStrategy = IClassChainSearch::name;
            break;
        case IClassChainSearch::value:
            $this->locatorStrategy = IClassChainSearch::value;
            break;
    }
}

$this->test->setLocatorStrategy(ILocatorStrategy::accessibility_id);

public static $button = "**/XCUIElementTypeButton[%s == '%s']";

public static $button = "**/XCUIElementTypeButton['label' == '%s']";

$this->test->setClassChainSearch(IClassChainSearch::name);

OR

$this->test->setClassChainSearch(IClassChainSearch::value);

$this->test->clickOnButton('SIGN UP', 400);
$this->test->setLocatorStrategy("name");
$this->test->clickOnButton('button_name', 400);
$this->test->setLocatorStrategy("value");
$this->test->clickOnButton('button_value', 400);