mirror of
https://github.com/appium/appium.git
synced 2026-01-25 03:38:52 -06:00
@@ -59,7 +59,7 @@ if $ios_only || $all_tests; then
|
||||
echo "RUNNING IOS 6.1 TESTS"
|
||||
echo "---------------------"
|
||||
ios_testfile="./test/functional/_joined/ios.js"
|
||||
ios_dirs="prefs safari testapp uicatalog webview appium"
|
||||
ios_dirs="appium prefs safari testapp uicatalog webview appium gappium"
|
||||
join_testfiles ios6.1 $ios_testfile $ios_dirs
|
||||
if test -d /Applications/Xcode-6.1.app; then
|
||||
echo "Found Xcode for iOS 6.1, switching to it"
|
||||
@@ -75,7 +75,7 @@ if $ios7_only || $all_tests; then
|
||||
echo "RUNNING IOS 7.0 TESTS"
|
||||
echo "---------------------"
|
||||
ios7_testfile="./test/functional/_joined/ios7.js"
|
||||
ios7_dirs="testapp uicatalog webview iwebview"
|
||||
ios7_dirs="testapp safari uicatalog webview gappium"
|
||||
join_testfiles ios7 $ios7_testfile $ios7_dirs
|
||||
if test -d /Applications/Xcode-7.0.app; then
|
||||
echo "Found Xcode for iOS 7.0, switching to it"
|
||||
@@ -96,7 +96,7 @@ if $android_only || $all_tests; then
|
||||
echo "RUNNING ANDROID TESTS"
|
||||
echo "---------------------"
|
||||
android_testfile="./test/functional/_joined/android.js"
|
||||
android_dirs="apidemos selendroid android"
|
||||
android_dirs="apidemos selendroid android gappium"
|
||||
join_testfiles android $android_testfile $android_dirs
|
||||
time $appium_mocha $android_testfile
|
||||
APPIUM_CORDOVA="android" time $appium_mocha $android_testfile
|
||||
fi
|
||||
|
||||
@@ -18,6 +18,7 @@ var _ = require("underscore")
|
||||
, fs = require('fs')
|
||||
, helpers = require('./lib/helpers')
|
||||
, isWindows = helpers.isWindows()
|
||||
, getXcodeFolder = helpers.getXcodeFolder
|
||||
, getXcodeVersion = helpers.getXcodeVersion
|
||||
, MAX_BUFFER_SIZE = 524288;
|
||||
|
||||
@@ -191,16 +192,34 @@ var auth_updateSecurityDb = function(grunt, insecure, cb) {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.authorize = function(grunt, insecure, cb) {
|
||||
auth_enableDevTools(grunt, function(err) {
|
||||
if (err) grunt.fatal(err);
|
||||
auth_updateSecurityDb(grunt, insecure, function(err) {
|
||||
var auth_chmodApps = function(grunt, cb) {
|
||||
grunt.log.writeln("Granting access to built-in simulator apps");
|
||||
var user;
|
||||
if (!process.env.HOME) {
|
||||
grunt.fatal(new Error("Could not determine your $HOME"));
|
||||
} else {
|
||||
user = /\/([^\/]+)$/.exec(process.env.HOME)[1];
|
||||
}
|
||||
getXcodeFolder(function(err, xcodeDir) {
|
||||
if (err) return cb(err);
|
||||
var glob = path.resolve(xcodeDir, "Platforms/iPhoneSimulator.platform/" +
|
||||
"Developer/SDKs/iPhoneSimulator*.sdk/Applications");
|
||||
var cmd = "chown -R " + user + ": " + glob;
|
||||
exec(cmd, function(err) {
|
||||
if (err) grunt.fatal(err);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.authorize = function(grunt, insecure, cb) {
|
||||
auth_enableDevTools(grunt, function() {
|
||||
auth_updateSecurityDb(grunt, insecure, function() {
|
||||
auth_chmodApps(grunt, cb);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.build = function(appRoot, cb, sdk, xcconfig) {
|
||||
var next = function() {
|
||||
var cmd = 'xcodebuild -sdk ' + sdk + ' clean';
|
||||
|
||||
@@ -10,6 +10,7 @@ var routing = require('./server/routing.js')
|
||||
, checkSafari = helpers.checkSafari
|
||||
, cleanSafari = helpers.cleanSafari
|
||||
, copyLocalZip = helpers.copyLocalZip
|
||||
, getiOSSDKVersion = helpers.getiOSSDKVersion
|
||||
, UUID = require('uuid-js')
|
||||
, _ = require('underscore')
|
||||
, fs = require('fs')
|
||||
@@ -44,6 +45,7 @@ var Appium = function(args) {
|
||||
this.origCommandTimeoutMs = this.commandTimeoutMs;
|
||||
this.commandTimeout = null;
|
||||
this.isSafariLauncherApp = false;
|
||||
this.origAppPath = null;
|
||||
};
|
||||
|
||||
Appium.prototype.attachTo = function(rest, cb) {
|
||||
@@ -253,14 +255,7 @@ Appium.prototype.configureApp = function(desiredCaps, hasAppInCaps, cb) {
|
||||
this.isSafariLauncherApp = true;
|
||||
this.configureLocalApp("./build/SafariLauncher/SafariLauncher.zip", origin, cb);
|
||||
} else {
|
||||
if (parseFloat(this.desiredCapabilities.version) >= 7) {
|
||||
this.configureSafariForLauncher(desiredCaps, function() {
|
||||
this.isSafariLauncherApp = true;
|
||||
this.configureLocalApp("./build/SafariLauncher/SafariLauncherSim.zip", origin, cb);
|
||||
}.bind(this));
|
||||
} else {
|
||||
this.configureSafari(desiredCaps, cb);
|
||||
}
|
||||
this.configureSafari(desiredCaps, cb);
|
||||
}
|
||||
} else if (this.isIos() && appPath.toLowerCase() === "iwebview") {
|
||||
this.desiredCapabilities.iwebview = true;
|
||||
@@ -360,52 +355,44 @@ Appium.prototype.configureDownloadedApp = function(appPath, origin, cb) {
|
||||
|
||||
Appium.prototype.configureSafari = function(desiredCaps, cb) {
|
||||
this.desiredCapabilities.safari = true;
|
||||
var safariVer = "6.1";
|
||||
var usingDefaultVer = true;
|
||||
if (typeof desiredCaps.version !== "undefined") {
|
||||
var safariVer = null;
|
||||
if (typeof desiredCaps.version !== "undefined" && desiredCaps.version) {
|
||||
safariVer = desiredCaps.version;
|
||||
usingDefaultVer = false;
|
||||
}
|
||||
logger.info("Trying to use mobile safari, version " + safariVer);
|
||||
var checkSuccess = function(attemptedApp) {
|
||||
var checkNext = function(attemptedApp, origApp, safariVer) {
|
||||
logger.info("Using mobile safari app at " + attemptedApp);
|
||||
this.args.app = attemptedApp;
|
||||
cleanSafariNext();
|
||||
}.bind(this);
|
||||
var cleanSafariNext = function() {
|
||||
logger.info("Cleaning mobile safari data files");
|
||||
cleanSafari(safariVer, function(err) {
|
||||
if (err) {
|
||||
logger.error(err.message);
|
||||
cb(err);
|
||||
} else {
|
||||
this.origAppPath = origApp;
|
||||
cb(null);
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this);
|
||||
var sdkNext = function(safariVer) {
|
||||
checkSafari(safariVer, function(err, attemptedApp, origApp) {
|
||||
if (err) {
|
||||
logger.error("Could not prepare mobile safari with version '" +
|
||||
safariVer + "': " + err);
|
||||
return cb(err);
|
||||
}
|
||||
checkNext(attemptedApp, origApp, safariVer);
|
||||
});
|
||||
};
|
||||
|
||||
checkSafari(safariVer, function(err, attemptedApp) {
|
||||
if (err) {
|
||||
logger.warn("Could not find mobile safari with version '" + safariVer +
|
||||
"': " + err);
|
||||
if (usingDefaultVer) {
|
||||
safariVer = "6.1";
|
||||
logger.info("Retrying with safari ver " + safariVer);
|
||||
checkSafari(safariVer, function(err, attemptedApp) {
|
||||
if (err) {
|
||||
logger.warn("Could not find this one either: " + err);
|
||||
cb(err);
|
||||
} else {
|
||||
checkSuccess(attemptedApp);
|
||||
}
|
||||
}.bind(this));
|
||||
} else {
|
||||
cb(err);
|
||||
}
|
||||
} else {
|
||||
checkSuccess(attemptedApp);
|
||||
}
|
||||
}.bind(this));
|
||||
if (safariVer === null) {
|
||||
getiOSSDKVersion(function(err, safariVer) {
|
||||
if (err) return cb(err);
|
||||
sdkNext(safariVer);
|
||||
});
|
||||
} else {
|
||||
sdkNext(safariVer);
|
||||
}
|
||||
};
|
||||
|
||||
Appium.prototype.configureSafariForLauncher = function (desiredCaps, cb) {
|
||||
@@ -547,6 +534,7 @@ Appium.prototype.initDevice = function() {
|
||||
, desiredCapabilities: this.desiredCapabilities
|
||||
, logNoColors: this.args.logNoColors
|
||||
, flakeyRetries: this.args.backendRetries
|
||||
, origAppPath: this.origAppPath
|
||||
};
|
||||
if (this.desiredCapabilities.safari || this.desiredCapabilities.iwebview) {
|
||||
this.device = new Safari(iosOpts);
|
||||
|
||||
@@ -20,6 +20,8 @@ var ERR_NEVER_CHECKED_IN = "Instruments never checked in"
|
||||
var Instruments = function(opts) {
|
||||
this.app = opts.app;
|
||||
this.launchTimeout = opts.launchTimeout || 90000;
|
||||
this.killTimeout = 6000;
|
||||
this.killTimer = null;
|
||||
this.flakeyRetries = opts.flakeyRetries;
|
||||
this.launchTries = 0;
|
||||
this.neverConnected = false;
|
||||
@@ -115,8 +117,13 @@ Instruments.prototype.launchHandler = function(err) {
|
||||
|
||||
Instruments.prototype.killProc = function() {
|
||||
if (this.proc !== null) {
|
||||
logger.info("Sending sigterm to instruments");
|
||||
this.proc.kill('SIGTERM');
|
||||
logger.info("Sending sigkill to instruments");
|
||||
this.killTimer = setTimeout(function() {
|
||||
logger.info("Instruments didn't die after " + (this.killTimeout / 1000) +
|
||||
" seconds; abandoning it completely");
|
||||
this.onInstrumentsExit(1);
|
||||
}.bind(this), this.killTimeout);
|
||||
this.proc.kill('SIGKILL');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -257,6 +264,7 @@ Instruments.prototype.spawnInstruments = function(tmpDir) {
|
||||
};
|
||||
|
||||
Instruments.prototype.onInstrumentsExit = function(code) {
|
||||
clearTimeout(this.killTimer);
|
||||
this.debug("Instruments exited with code " + code);
|
||||
|
||||
if (this.neverConnected) {
|
||||
|
||||
@@ -221,24 +221,46 @@ iOSController.click = function(elementId, cb) {
|
||||
this.executeAtom('tap', [atomsElement], cb);
|
||||
}.bind(this));
|
||||
} else {
|
||||
if (this.useRobot) {
|
||||
var locCmd = "au.getElement('" + elementId + "').rect()";
|
||||
this.proxy(locCmd, function(err, res) {
|
||||
if (err) return cb(err, res);
|
||||
var rect = res.value;
|
||||
var pos = {x: rect.origin.x, y: rect.origin.y};
|
||||
var size = {w: rect.size.width, h: rect.size.height};
|
||||
var tapPoint = { x: pos.x + (size.w/2), y: pos.y + (size.h/2) };
|
||||
var tapUrl = this.robotUrl + "/tap/x/" + tapPoint.x + "/y/" + tapPoint.y;
|
||||
request.get(tapUrl, {}, cb);
|
||||
}.bind(this));
|
||||
} else {
|
||||
if (this.useRobot) {
|
||||
var locCmd = "au.getElement('" + elementId + "').rect()";
|
||||
this.proxy(locCmd, function(err, res) {
|
||||
if (err) return cb(err, res);
|
||||
var rect = res.value;
|
||||
var pos = {x: rect.origin.x, y: rect.origin.y};
|
||||
var size = {w: rect.size.width, h: rect.size.height};
|
||||
var tapPoint = { x: pos.x + (size.w/2), y: pos.y + (size.h/2) };
|
||||
var tapUrl = this.robotUrl + "/tap/x/" + tapPoint.x + "/y/" + tapPoint.y;
|
||||
request.get(tapUrl, {}, cb);
|
||||
}.bind(this));
|
||||
} else {
|
||||
var command = ["au.tapById('", elementId, "')"].join('');
|
||||
this.proxy(command, cb);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
iOSController.nonSyntheticWebClick = function(elementId, cb) {
|
||||
this.useAtomsElement(elementId, cb, function(atomsElement) {
|
||||
this.executeAtom('get_top_left_coordinates', [atomsElement], function(err, res) {
|
||||
if (err || res.status !== 0) return cb(err, res);
|
||||
var x = res.value.x, y = res.value.y;
|
||||
this.executeAtom('get_size', [atomsElement], function(err, res) {
|
||||
if (err || res.status !== 0) return cb(err, res);
|
||||
var w = res.value.width, h = res.value.height;
|
||||
var clickX = x + (w / 2);
|
||||
var clickY = y + (h / 2);
|
||||
this.curWebCoords = {x: clickX, y: clickY};
|
||||
this.clickWebCoords(function(err, res) {
|
||||
// make sure real tap actually has time to register
|
||||
setTimeout(function() {
|
||||
cb(err, res);
|
||||
}, 500);
|
||||
});
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
iOSController.touchLongClick = function(elementId, cb) {
|
||||
cb(new NotYetImplementedError(), null);
|
||||
};
|
||||
@@ -367,8 +389,8 @@ iOSController.clickCurrent = function(button, cb) {
|
||||
|
||||
iOSController.clickCoords = function(coords, cb) {
|
||||
if (this.useRobot) {
|
||||
var tapUrl = this.robotUrl + "/tap/x/" + coords.x + "/y/" + coords.y;
|
||||
request.get(tapUrl, {}, cb);
|
||||
var tapUrl = this.robotUrl + "/tap/x/" + coords.x + "/y/" + coords.y;
|
||||
request.get(tapUrl, {}, cb);
|
||||
} else {
|
||||
var opts = coords;
|
||||
opts.tapCount = 1;
|
||||
@@ -421,6 +443,8 @@ iOSController.clickWebCoords = function(cb) {
|
||||
x: wvPos.x + (xRatio * coords.x)
|
||||
, y: wvPos.y + (yRatio * coords.y) - serviceBarHeight
|
||||
};
|
||||
logger.info("Converted web coords " + JSON.stringify(this.curWebCoords) +
|
||||
"into real coords " + JSON.stringify(coords));
|
||||
this.clickCoords(coords, cb);
|
||||
}
|
||||
}.bind(this);
|
||||
@@ -575,15 +599,9 @@ iOSController.getWindowSize = function(windowHandle, cb) {
|
||||
}
|
||||
};
|
||||
|
||||
iOSController.mobileSafariNav = function(navBtnName, cb) {
|
||||
this.findUIElementOrElements('xpath', '//toolbar/button[@name="' + navBtnName + '"]',
|
||||
null, false, function(err, res) {
|
||||
if (this.checkSuccess(err, res, cb)) {
|
||||
var cmd = "au.getElement(" + res.value.ELEMENT + ").tap()";
|
||||
this.remote.willNavigateWithoutReload = true;
|
||||
this.proxy(cmd, cb);
|
||||
}
|
||||
}.bind(this));
|
||||
iOSController.mobileWebNav = function(navType, cb) {
|
||||
this.remote.willNavigateWithoutReload = true;
|
||||
this.executeAtom('execute_script', ['history.' + navType + '();', null], cb);
|
||||
};
|
||||
|
||||
iOSController.back = function(cb) {
|
||||
@@ -591,7 +609,7 @@ iOSController.back = function(cb) {
|
||||
var command = "au.back();";
|
||||
this.proxy(command, cb);
|
||||
} else {
|
||||
this.mobileSafariNav("Back", cb);
|
||||
this.mobileWebNav("back", cb);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -599,7 +617,7 @@ iOSController.forward = function(cb) {
|
||||
if (this.curWindowHandle === null) {
|
||||
cb(new NotImplementedError(), null);
|
||||
} else {
|
||||
this.mobileSafariNav("Forward", cb);
|
||||
this.mobileWebNav("forward", cb);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1133,12 +1151,12 @@ iOSController.getWindowHandles = function(cb) {
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
iOSController.setWindow = function(name, cb) {
|
||||
iOSController.setWindow = function(name, cb, skipReadyCheck) {
|
||||
if (_.contains(_.pluck(this.windowHandleCache, 'id'), name)) {
|
||||
var pageIdKey = parseInt(name, 10);
|
||||
var next = function() {
|
||||
this.processingRemoteCmd = true;
|
||||
if(this.udid === null) {
|
||||
if (this.udid === null) {
|
||||
this.remote.selectPage(pageIdKey, function() {
|
||||
this.curWindowHandle = pageIdKey.toString();
|
||||
cb(null, {
|
||||
@@ -1146,7 +1164,7 @@ iOSController.setWindow = function(name, cb) {
|
||||
, value: ''
|
||||
});
|
||||
this.processingRemoteCmd = false;
|
||||
}.bind(this));
|
||||
}.bind(this), skipReadyCheck);
|
||||
} else {
|
||||
if (name == this.curWindowHandle){
|
||||
logger.info("Remote debugger is already connected to window [" + name + "]");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
var path = require('path')
|
||||
, rimraf = require('rimraf')
|
||||
, ncp = require('ncp').ncp
|
||||
, fs = require('fs')
|
||||
, _ = require('underscore')
|
||||
, logger = require('../../server/logger.js').get('appium')
|
||||
@@ -44,6 +45,7 @@ IOS.prototype.init = function(args) {
|
||||
this.webSocket = args.webSocket;
|
||||
this.launchTimeout = args.launchTimeout;
|
||||
this.app = args.app;
|
||||
this.origAppPath = args.origAppPath;
|
||||
this.ipa = args.ipa;
|
||||
this.bundleId = args.bundleId || null;
|
||||
this.udid = args.udid;
|
||||
@@ -235,6 +237,11 @@ IOS.prototype.startInstruments = function(cb) {
|
||||
IOS.prototype.onInstrumentsLaunch = function(cb) {
|
||||
logger.info('Instruments launched. Starting poll loop for new commands.');
|
||||
this.instruments.setDebug(true);
|
||||
if (this.origAppPath) {
|
||||
logger.info("Copying app back to its original place");
|
||||
return ncp(this.app, this.origAppPath, cb);
|
||||
}
|
||||
|
||||
cb();
|
||||
};
|
||||
|
||||
@@ -818,7 +825,10 @@ IOS.prototype.shutdown = function(code, traceDir, cb) {
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
async.series([removeTraceDir, this.postCleanup.bind(this)], function() {
|
||||
async.series([
|
||||
removeTraceDir,
|
||||
this.postCleanup.bind(this)
|
||||
], function() {
|
||||
cb();
|
||||
});
|
||||
|
||||
|
||||
@@ -371,13 +371,19 @@ RemoteDebugger.prototype.pageLoad = function() {
|
||||
});
|
||||
} else {
|
||||
logger.debug("Page was not ready, retrying");
|
||||
setTimeout(verify, intMs);
|
||||
this.loadingTimeout = setTimeout(verify, intMs);
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this);
|
||||
verify();
|
||||
};
|
||||
|
||||
RemoteDebugger.prototype.cancelPageLoad = function() {
|
||||
this.pageLoadedCbs = [];
|
||||
this.pageLoading = false;
|
||||
clearTimeout(this.loadingTimeout);
|
||||
};
|
||||
|
||||
RemoteDebugger.prototype.frameNavigated = function() {
|
||||
logger.info("Frame navigated, calling cbs");
|
||||
clearTimeout(this.navigatingTimeout);
|
||||
|
||||
@@ -30,28 +30,51 @@ Safari.prototype.navToInitialWebview = function(cb) {
|
||||
};
|
||||
|
||||
Safari.prototype.navToLatestAvailableWebview = function(cb) {
|
||||
logger.info("Navigating to most recently opened webview");
|
||||
var start = Date.now();
|
||||
var spinHandles = function() {
|
||||
this.getWindowHandles(function(err, res) {
|
||||
if (res.status !== 0) {
|
||||
cb(new Error("Could not navigate to webview! Code: " + res.status));
|
||||
} else if (res.value.length < 1) {
|
||||
if ((Date.now() - start) < 6000) {
|
||||
logger.warn("Could not find any webviews yet, retrying");
|
||||
return setTimeout(spinHandles, 500);
|
||||
var navToView = function() {
|
||||
logger.info("Navigating to most recently opened webview");
|
||||
var start = Date.now();
|
||||
var spinHandles = function() {
|
||||
this.getWindowHandles(function(err, res) {
|
||||
if (res.status !== 0) {
|
||||
cb(new Error("Could not navigate to webview! Code: " + res.status));
|
||||
} else if (res.value.length < 1) {
|
||||
if ((Date.now() - start) < 6000) {
|
||||
logger.warn("Could not find any webviews yet, retrying");
|
||||
return setTimeout(spinHandles, 500);
|
||||
}
|
||||
cb(new Error("Could not navigate to webview; there aren't any!"));
|
||||
} else {
|
||||
logger.info("Picking webview " + res.value[0]);
|
||||
this.setWindow(res.value[res.value.length - 1], function(err) {
|
||||
if (err) return cb(err);
|
||||
this.remote.cancelPageLoad();
|
||||
cb();
|
||||
}.bind(this), true);
|
||||
}
|
||||
cb(new Error("Could not navigate to webview; there aren't any!"));
|
||||
} else {
|
||||
logger.info("Picking webview " + res.value[0]);
|
||||
this.setWindow(res.value[res.value.length - 1], function(err) {
|
||||
if (err) return cb(err);
|
||||
cb();
|
||||
});
|
||||
}.bind(this));
|
||||
}.bind(this);
|
||||
spinHandles();
|
||||
}.bind(this);
|
||||
if (parseInt(this.iOSSDKVersion, 10) >= 7) {
|
||||
logger.info("We're on iOS7: clicking apple button to get into a webview");
|
||||
this.findAndAct('xpath', '//window[2]/scrollview[1]/button[1]', 0, 'click', [], function(err, res) {
|
||||
if (this.checkSuccess(err, res, cb)) {
|
||||
navToView();
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this);
|
||||
spinHandles();
|
||||
} else {
|
||||
navToView();
|
||||
}
|
||||
};
|
||||
|
||||
Safari.prototype._click = IOS.prototype.click;
|
||||
Safari.prototype.click = function(elementId, cb) {
|
||||
if (parseInt(this.iOSSDKVersion, 10) >= 7) {
|
||||
// atoms-based clicks don't always work in safari 7
|
||||
this.nonSyntheticWebClick(elementId, cb);
|
||||
} else {
|
||||
this._click(elementId, cb);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Safari;
|
||||
|
||||
@@ -133,21 +133,16 @@ exports.unzipApp = function(zipPath, appExt, cb) {
|
||||
exports.checkBuiltInApp = function(appName, version, cb) {
|
||||
logger.info("Looking for built in app " + appName);
|
||||
exports.getBuiltInAppDir(version, function(err, appDir) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else {
|
||||
var appPath = path.resolve(appDir, appName + ".app");
|
||||
fs.stat(appPath, function(err, s) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else if (!s.isDirectory()) {
|
||||
cb("App package was not a directory", appPath);
|
||||
} else {
|
||||
logger.info("Got app, trying to copy " + appPath + " to tmp dir");
|
||||
exports.copyBuiltInApp(appPath, appName, cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (err) return cb(err);
|
||||
var appPath = path.resolve(appDir, appName + ".app");
|
||||
fs.stat(appPath, function(err, s) {
|
||||
if (err) return cb(err);
|
||||
if (!s.isDirectory()) {
|
||||
return cb(new Error("App package was not a directory"), appPath);
|
||||
}
|
||||
logger.info("Got app, trying to copy " + appPath + " to tmp dir");
|
||||
exports.moveBuiltInApp(appPath, appName, cb);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -170,7 +165,7 @@ exports.getBuiltInAppDir = function(version, cb) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else if (!s.isDirectory()) {
|
||||
cb("Could not load built in applications directory");
|
||||
cb(new Error("Could not load built in applications directory"));
|
||||
} else {
|
||||
cb(null, appDir);
|
||||
}
|
||||
@@ -178,15 +173,22 @@ exports.getBuiltInAppDir = function(version, cb) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.copyBuiltInApp = function(appPath, appName, cb) {
|
||||
exports.moveBuiltInApp = function(appPath, appName, cb) {
|
||||
var newAppDir = path.resolve(exports.getTempPath(), 'Appium-' + appName + '.app');
|
||||
ncp(appPath, newAppDir, function(err) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else {
|
||||
logger.info("Copied " + appName + " to " + newAppDir);
|
||||
cb(null, newAppDir);
|
||||
}
|
||||
if (err) return cb(err);
|
||||
logger.info("Copied " + appName + " to " + newAppDir);
|
||||
rimraf(appPath, function(err) {
|
||||
if (err) {
|
||||
if (err.message.indexOf("EACCES") !== -1) {
|
||||
return cb(new Error("We don't have write access to " + appPath +
|
||||
", please re-run authorize as " + process.env.USER));
|
||||
}
|
||||
return cb(err);
|
||||
}
|
||||
logger.info("Temporarily deleted original app at " + appPath);
|
||||
cb(null, newAppDir, appPath);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ var args = [
|
||||
, help: "(IOS-Simulator-only) name of the iOS device to use"
|
||||
}],
|
||||
|
||||
[['--default-device'], {
|
||||
[['--default-device', '-dd'], {
|
||||
dest: 'defaultDevice'
|
||||
, defaultValue: false
|
||||
, action: 'storeTrue'
|
||||
|
||||
14
reset.sh
14
reset.sh
@@ -180,18 +180,12 @@ reset_ios() {
|
||||
run_cmd rm -rf build/fruitstrap
|
||||
run_cmd mkdir -p build/fruitstrap
|
||||
run_cmd cp submodules/fruitstrap/fruitstrap build/fruitstrap
|
||||
echo "* Cloning/updating SafariLauncher"
|
||||
run_cmd git submodule update --init submodules/SafariLauncher
|
||||
echo "* Building SafariLauncher"
|
||||
run_cmd rm -f submodules/Safarilauncher/target.xcconfig
|
||||
echo "BUNDLE_ID = com.bytearc.SafariLauncher" >> submodules/Safarilauncher/target.xcconfig
|
||||
run_cmd $grunt buildSafariLauncherApp:iphonesimulator:"target.xcconfig"
|
||||
echo "* Copying SafariLauncher to build"
|
||||
run_cmd rm -rf build/SafariLauncher
|
||||
run_cmd mkdir -p build/SafariLauncher
|
||||
run_cmd zip -r build/SafariLauncher/SafariLauncherSim submodules/SafariLauncher/build/Release-iphonesimulator/SafariLauncher.app
|
||||
if $should_reset_realsafari; then
|
||||
echo "* Cloning/updating SafariLauncher"
|
||||
run_cmd git submodule update --init submodules/SafariLauncher
|
||||
echo "* Building SafariLauncher for real devices"
|
||||
run_cmd rm -rf build/SafariLauncher
|
||||
run_cmd mkdir -p build/SafariLauncher
|
||||
run_cmd rm -f submodules/Safarilauncher/target.xcconfig
|
||||
echo "BUNDLE_ID = com.bytearc.SafariLauncher" >> submodules/Safarilauncher/target.xcconfig
|
||||
if [[ ! -z $code_sign_identity ]]; then
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
var path = require('path')
|
||||
, describeWd = null
|
||||
, appPkg = "io.appium.gappium.sampleapp"
|
||||
, appAct = "HelloGappium"
|
||||
, appPath = path.resolve(__dirname, "../../../sample-code/apps/" + appPkg + "/platforms/ios/build/" + appAct + ".app")
|
||||
, appAct = ".HelloGappium"
|
||||
, appPath = path.resolve(__dirname, "../../../sample-code/apps/" + appPkg + "/platforms/ios/build/HelloGappium.app")
|
||||
, driverBlock = require("../../helpers/driverblock.js")
|
||||
, it = driverBlock.it
|
||||
, should = require('should');
|
||||
|
||||
// export env APPIUM_CORDOVA="android" to run tests against android version
|
||||
if (typeof process.env.APPIUM_CORDOVA !== "undefined" && process.env.APPIUM_CORDOVA === "android") {
|
||||
appPath = path.resolve(__dirname, "../../../sample-code/apps/" + appPkg + "/platforms/android/bin/" + appAct + "-debug.apk");
|
||||
appPath = path.resolve(__dirname, "../../../sample-code/apps/" + appPkg + "/platforms/android/bin/HelloGappium-debug.apk");
|
||||
describeWd = driverBlock.describeForApp(appPath, "selendroid", appPkg, appAct);
|
||||
} else {
|
||||
describeWd = driverBlock.describeForApp(appPath, "ios", appPkg, appAct);
|
||||
@@ -10,7 +10,6 @@ var desc = require("../../helpers/driverblock.js").describeForSafari()
|
||||
, should = require('should');
|
||||
|
||||
|
||||
//var devices = ["iPhone", "iPad"];
|
||||
var devices = ["iPad", "iPhone"];
|
||||
_.each(devices, function(sim) {
|
||||
|
||||
|
||||
@@ -8,13 +8,11 @@ var wd = require('wd')
|
||||
, path = require("path")
|
||||
, defaultHost = '127.0.0.1'
|
||||
, defaultPort = process.env.APPIUM_PORT || 4723
|
||||
, defaultIosVer = '7.0'
|
||||
, domain = require('domain')
|
||||
, defaultCaps = {
|
||||
browserName: ''
|
||||
, device: 'iPhone Simulator'
|
||||
, platform: 'Mac'
|
||||
, version: defaultIosVer
|
||||
};
|
||||
|
||||
if (process.env.SAUCE_ACCESS_KEY && process.env.SAUCE_USERNAME) {
|
||||
@@ -30,7 +28,7 @@ var driverBlock = function(tests, host, port, caps, extraCaps) {
|
||||
port = (typeof port === "undefined" || port === null) ? _.clone(defaultPort) : port;
|
||||
caps = (typeof caps === "undefined" || caps === null) ? _.clone(defaultCaps) : caps;
|
||||
caps = _.extend(caps, typeof extraCaps === "undefined" ? {} : extraCaps);
|
||||
caps.launchTimeout = 30000;
|
||||
caps.launchTimeout = 15000;
|
||||
var driverHolder = {driver: null, sessionId: null};
|
||||
var expectConnError = extraCaps && extraCaps.expectConnError;
|
||||
|
||||
@@ -99,8 +97,6 @@ var describeForSafari = function() {
|
||||
browserName: 'Safari'
|
||||
, app: 'safari'
|
||||
, device: 'iPhone Simulator'
|
||||
, platform: 'Mac'
|
||||
, version: "6.1"
|
||||
};
|
||||
return describeWithDriver(desc, tests, host, port, caps, extraCaps, undefined, onlyify);
|
||||
};
|
||||
@@ -120,8 +116,6 @@ var describeForIWebView = function() {
|
||||
browserName: ''
|
||||
, app: 'iwebview'
|
||||
, device: 'iPhone Simulator'
|
||||
, platform: 'Mac'
|
||||
, version: "7.0"
|
||||
};
|
||||
return describeWithDriver(desc, tests, host, port, caps, extraCaps, undefined, onlyify);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user