update readme and example tests to use new way of starting app

This commit is contained in:
Jonathan Lipps
2013-01-25 11:28:47 -08:00
committed by Sebastian Tiedtke
parent 53d8fc1f2c
commit 18b647c9a4
8 changed files with 45 additions and 23 deletions

View File

@@ -22,7 +22,7 @@ Ninja-speed Setup
Install [node.js](http://nodejs.org/) which comes with its package manager [npm](https://npmjs.org/).
> sudo npm install appium -g
> appium --app /path/to/your/ios/app &
> appium &
> node your-appium-test.js
See [the appium example tests.](https://github.com/appium/appium/tree/master/sample-code/examples)
@@ -55,19 +55,15 @@ Build an app:
> grunt buildApp:UICatalog
> grunt buildApp:TestApp
Run functional tests against TestApp:
Run all functional tests:
> grunt functional
Run unit tests against TestApp:
Run unit tests:
> grunt unit
Run tests against UICatalog:
> grunt uicatalog
Run all tests against TestApp and UICatalog:
Run all tests:
> grunt test
@@ -82,19 +78,22 @@ Before commiting code please run grunt to run test and check your changes agains
More things, low-level things
-----------
If you want to run the appium server and have it listen indefinitely, you can
do one of the following:
do one of the following to start an appium server with or without an app
pre-specified:
> grunt appium
> grunt appium:TestApp
> grunt appium:UICatalog
Then you can, e.g., run individual testfiles using Mocha directly:
> mocha -t 60000 -R spec test/functional/simple.js
> mocha -t 60000 -R spec test/functional/testapp/simple.js
Do you like getting close to the metal? Or are you trying to run this from
a script with a custom app? Start appium without grunt from the
command line (see parser.js for more CLI arguments):
> node server.js -V 1
> node server.js --app /absolute/path/to/app -V 1
In this case, the app has to be compiled for the iphone simulator, e.g., by

View File

@@ -53,7 +53,10 @@ Appium.prototype.start = function(desiredCaps, cb) {
};
Appium.prototype.configure = function(desiredCaps, cb) {
if (typeof desiredCaps.app !== "undefined") {
var hasAppInCaps = (typeof desiredCaps !== "undefined" &&
typeof desiredCaps.app !== "undefined" &&
desiredCaps.app);
if (hasAppInCaps) {
if (desiredCaps.app[0] === "/") {
this.args.app = desiredCaps.app;
logger.info("Using local app from desiredCaps: " + desiredCaps.app);

View File

@@ -382,7 +382,7 @@ IOS.prototype.flickElement = function(elementId, xoffset, yoffset, speed, cb) {
IOS.prototype.url = function(cb) {
// in the future, detect whether we have a UIWebView that we can use to
// make sense of this command. For now, and otherwise, it's a no-op
cb(null, null);
cb(null, {status: status.codes.Success.code, value: ''});
};
IOS.prototype.active = function(cb) {

View File

@@ -62,7 +62,7 @@ module.exports = function(grunt) {
grunt.registerTask('default', 'lint test');
grunt.registerTask('appium', "Start the Appium server", function(appName) {
if (typeof appName === "undefined") {
appName = "TestApp";
appName = null;
}
startAppium(appName, true, function() {}, this.async());
});

View File

@@ -6,6 +6,11 @@
// https://github.com/giorgiosironi/phpunit-selenium/pull/18
require_once "vendor/autoload.php";
define("APP_PATH", realpath(dirname(__FILE__).'/../../apps/UICatalog/build/Release-iphonesimulator/UICatalog.app'));
if (!APP_PATH) {
die("App did not exist!");
}
class SimpleTest extends Sauce\Sausage\WebDriverTestCase
{
@@ -18,7 +23,8 @@ class SimpleTest extends Sauce\Sausage\WebDriverTestCase
'browserName' => 'iOS',
'desiredCapabilities' => array(
'version' => '6.0',
'platform' => 'Mac'
'platform' => 'Mac',
'app' => APP_PATH
)
)
);
@@ -45,6 +51,5 @@ class SimpleTest extends Sauce\Sausage\WebDriverTestCase
$buttons[0]->click();
$texts = $this->elemsByTag('staticText');
$this->assertEquals(array_sum($this->numValues), (int)($texts[0]->text()));
sleep(10);
}
}

View File

@@ -5,6 +5,7 @@ Before running the test make sure you started appium server
with TestApp app: grunt appium:TestApp
"""
import unittest
import os
from random import randint
from selenium import webdriver
@@ -13,12 +14,17 @@ class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
# set up appium
app = os.path.join(os.path.dirname(__file__),
'../../apps/TestApp/build/Release-iphonesimulator',
'TestApp.app')
app = os.path.abspath(app)
self.driver = webdriver.Remote(
command_executor='http://127.0.0.1:4723/wd/hub',
desired_capabilities={
'browserName': 'iOS',
'platform': 'Mac',
'version': '6.0'
'version': '6.0',
'app': app
})
self._values = []

View File

@@ -7,6 +7,7 @@ with UICatalog app: grunt appium:UICatalog
TODO: flick, drag etc.
"""
import unittest
import os
import random
import string
from selenium import webdriver
@@ -24,13 +25,18 @@ class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
# set up appium
app = os.path.join(os.path.dirname(__file__),
'../../apps/UICatalog/build/Release-iphonesimulator',
'UICatalog.app')
app = os.path.abspath(app)
self.driver = webdriver.Remote(
command_executor='http://127.0.0.1:4723/wd/hub',
desired_capabilities={
'browserName': 'iOS',
'platform': 'Mac',
'version': '6.0'
})
command_executor='http://127.0.0.1:4723/wd/hub',
desired_capabilities={
'browserName': 'iOS',
'platform': 'Mac',
'version': '6.0',
'app': app
})
self._values = []
def _open_menu_position(self, index):

View File

@@ -24,10 +24,13 @@ var main = function(args, readyCb, doneCb) {
req.headers['content-length'] = 0;
next();
} else {
// hack because python client library sux
if (req.headers['content-type'] === 'application/x-www-form-urlencoded') {
req.headers['content-type'] = 'application/json';
}
bodyParser(req, res, next);
}
};
rest.use(function(req, res, next) {
next();
});