Repository: cordova-medic Updated Branches: refs/heads/master be6fc18a9 -> 1aa20535f
CB-11232: - Adding whitelist rule to config.xml before Appium tests launch - Fixed tapElementByXPath to correctly tap on elements when their location has a fractional number Project: http://git-wip-us.apache.org/repos/asf/cordova-medic/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-medic/commit/1aa20535 Tree: http://git-wip-us.apache.org/repos/asf/cordova-medic/tree/1aa20535 Diff: http://git-wip-us.apache.org/repos/asf/cordova-medic/diff/1aa20535 Branch: refs/heads/master Commit: 1aa20535f94705f3f8635364974c020ef12e8eb8 Parents: be6fc18 Author: Alexander Sorokin <alexander.soro...@akvelon.com> Authored: Wed May 11 17:31:24 2016 +0300 Committer: Alexander Sorokin <alexander.soro...@akvelon.com> Committed: Fri May 13 11:43:31 2016 +0300 ---------------------------------------------------------------------- lib/appium/helpers/wdHelper.js | 12 +++++++----- medic/medic-appium.js | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/1aa20535/lib/appium/helpers/wdHelper.js ---------------------------------------------------------------------- diff --git a/lib/appium/helpers/wdHelper.js b/lib/appium/helpers/wdHelper.js index 766e2ee..367e425 100644 --- a/lib/appium/helpers/wdHelper.js +++ b/lib/appium/helpers/wdHelper.js @@ -134,7 +134,7 @@ module.exports.configureLogging = function (driver) { module.exports.tapElementByXPath = function (xpath, driver) { return driver - .waitForElementByXPath(xpath, 60000) + .waitForElementByXPath(xpath, 30000) .getLocation() .then(function (loc) { if (loc.x <= 0) { @@ -143,10 +143,12 @@ module.exports.tapElementByXPath = function (xpath, driver) { if (loc.y <= 0) { loc.y = 1; } + loc.x = Math.floor(loc.x + 1); + loc.y = Math.floor(loc.y + 1); + var wd = module.exports.getWD(); - var tapChoose = new wd.TouchAction(); - tapChoose.tap(loc); - return driver - .performTouchAction(tapChoose); + var tapElement = new wd.TouchAction(); + tapElement.tap(loc); + return driver.performTouchAction(tapElement); }); }; http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/1aa20535/medic/medic-appium.js ---------------------------------------------------------------------- diff --git a/medic/medic-appium.js b/medic/medic-appium.js index 64f034a..7bc4637 100644 --- a/medic/medic-appium.js +++ b/medic/medic-appium.js @@ -293,6 +293,23 @@ function setPreference(appPath, preference, value) { fs.writeFileSync(configFile, xml.write({indent: 4}), util.DEFAULT_ENCODING); } +function permitAccess(appPath, origin) { + var configFile = getConfigPath(appPath); + var xml = parseElementtreeSync(configFile); + var rule = xml.find("access[@origin=\"" + origin + "\"]"); + + util.medicLog("Adding a whitelist 'access' rule for origin: " + origin); + + if (rule) { + util.medicLog("It is already in place"); + } else { + rule = new elementTree.Element("access"); + rule.attrib.origin = origin; + xml.getroot().append(rule); + fs.writeFileSync(configFile, xml.write({indent: 4}), util.DEFAULT_ENCODING); + } +} + // remove medic.json and rebuild the app function prepareApp(options, callback) { var fullAppPath = getFullAppPath(options.appPath); @@ -312,6 +329,7 @@ function prepareApp(options, callback) { setPreference(fullAppPath, "CameraUsesGeolocation", "true"); } addCspSource(fullAppPath, "connect-src", "http://*"); + permitAccess(fullAppPath, "*"); // rebuild the app util.medicLog("Building the app..."); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org