A problem with: PHPUnitTestCase +WebDriver + Appium adn iOS mobile automation tests.

532 views
Skip to first unread message

Maria Machlowska

unread,
Sep 12, 2013, 7:06:34 AM9/12/13
to appium-...@googlegroups.com
Hi!
I want to run some autoamtion test for iOS in PHPUnit.
The only way (I have found so far) to do this is use WebDriverTestCase like it is in git's sample here.

But I don't want to extend the WebDriverTestCase class (I don't need Composer at all!). I want only PHPUnit_FrameworkTestCase, and a RemoteWebDriverElement  object from here. The problem is, that RemoteWebDriverElement does not have such capability as "app" implemented.
Is there any way to do this tests without sauce.io?

Coulde you let me know how?

Thanks a lot!

Jonathan Lipps

unread,
Sep 12, 2013, 8:07:00 AM9/12/13
to Maria Machlowska, appium-...@googlegroups.com
php-webdriver must have some way of starting a remotewebdriver with custom capabilities. Ask their support for help.

--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

David Luu

unread,
Sep 12, 2013, 8:48:22 PM9/12/13
to appium-...@googlegroups.com
It also depends on which PHP language binding you use, as there are several to pick from. But they're all pretty configurable in terms of desired capabilities.

For Facebook's binding take a look at the links below for reference. It's really easy to take the given examples for browser capabilties (e.g. FF profile, SauceLabs connection) and modify to connect to Appium instead. Maybe time for someone to update/add to that GitHub wiki on how to connect to Appium with that binding.


Just compose the app and related capabilities for Appium in the form of an array as given in the examples above.

Maria Machlowska

unread,
Sep 19, 2013, 7:08:41 AM9/19/13
to appium-...@googlegroups.com, Maria Machlowska
Thanks a lot!
I fixed it just by creating one array of desired capabilities (there is a double array in appium sample), and it works fine.

Ling-Yi Kung

unread,
Sep 19, 2013, 3:02:43 PM9/19/13
to appium-...@googlegroups.com, Maria Machlowska
Could you post an example of a test, please? (e.g. how you're connecting and starting a session, then clicking an example button) I'm trying to set up PHP tests using php-webdriver and PHPUnit as well.

Maria Machlowska

unread,
Sep 20, 2013, 3:57:03 AM9/20/13
to appium-...@googlegroups.com, Maria Machlowska
Ofcourse I can.
Here is an example of my test (PHPUnit Test Case):
<?php

require_once '/Users/mariann/Desktop/php-webdriver-master/lib/__init__.php';   //the binding from https://github.com/facebook/php-webdriver/blob/master/
require_once '/Users/mariann/Desktop/php-webdriver-master/lib/WebDriverBy.php';

//require_once '/Users/mariann/Documents/Composer/vendor/autoload.php';

define("APP_PATH", realpath('/Users/mariann/Documents/Appium/iOS/iPhoneCoreDataRecipes/build/Release-iphonesimulator/Recipes.app'));
if (!APP_PATH) {
    die("App did not exist!");
}


class SampleTest extends PHPUnit_Framework_TestCase {

  protected $driver;

 
  public function setUp() {
   
    $host = 'http://localhost:4723/wd/hub'; // this is the default
 
    $capabilities=array(
            'local' => true,
            'port' => 4723,
            'browserName' => 'iOS',
                'version' => '5.1',
                'platform' => 'Mac',
                'app' => APP_PATH

       
    );
    print_r($capabilities);
    $this->driver = new RemoteWebDriver($host, $capabilities);
    //$this->driver = open(APP_PATH);
  }


// test body
  public function test() {
   
   
    print_r($this->driver->findElement(WebDriverBy::name("Add"))); //button in navigation bar in my app
   
   
    $this->driver->findElement(WebDriverBy::name("Add"))->click(); //accessing an application element - button, unfortunately accessing an element using an xpath to it does not work ;(. They are working on it. See here for more details about the problem.
    $xpath = "//button[@name='Add']";
    $this->driver->findElement(WebDriverBy::xpath($xpath));
    $this->driver->click();
    //$this->driver->findElement(WebDriverBy::xpath("//window[1]/navigationBar[1]/button[2]"))->click(); // Scenariusz - pkt2
              
    $username = ("Mortencja");
    $pass = ("ponnie16");
  
  }



  public function tearDown() {
    if ($this->driver) {
      if ($this->hasFailed()) {
        //$this->driver->set_sauce_context("passed", false);
      } else {
       // $this->driver->set_sauce_context("passed", true);
      }
      $this->driver->quit();
    }
    parent::tearDown();
  }

}

Ling-Yi Kung

unread,
Sep 20, 2013, 6:26:26 PM9/20/13
to appium-...@googlegroups.com, Maria Machlowska
Awesome! That was exactly what I needed. Much appreciated - thank you!
Reply all
Reply to author
Forward
0 new messages