Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tests for close() for ipad too

  • Loading branch information...
commit b92894a2e649f4263a160bef0e395c2d76231700 1 parent e2d004e
@jlipps authored
Showing with 29 additions and 28 deletions.
  1. +27 −2 app/ios.js
  2. +2 −26 test/functional/safari/safari.js
View
29 app/ios.js
@@ -45,6 +45,7 @@ var IOS = function(args) {
this.implicitWaitMs = 0;
this.curCoords = null;
this.curWebCoords = null;
+ this.onPageChangeCb = null;
this.capabilities = {
version: '6.0'
, webStorageEnabled: false
@@ -333,7 +334,14 @@ IOS.prototype.onPageChange = function(pageArray) {
this.remote.selectPage(newPage, function() {
me.selectingNewPage = false;
me.curWindowHandle = newPage;
+ if (me.onPageChangeCb !== null) {
+ me.onPageChangeCb();
+ me.onPageChangeCb = null;
+ }
});
+ } else if (this.onPageChangeCb !== null) {
+ this.onPageChangeCb();
+ this.onPageChangeCb = null;
}
this.windowHandleCache = newIds;
};
@@ -1220,8 +1228,19 @@ IOS.prototype.setWindow = function(name, cb) {
};
IOS.prototype.closeWindow = function(cb) {
+ var me = this;
if (this.curWindowHandle) {
- this.closeSafariWindow(cb);
+ var closeFn = _.bind(this.closeIPhoneWindow, this);
+ if (this.deviceType === "ipad") {
+ closeFn = _.bind(this.closeIPadWindow, this);
+ }
+ closeFn(function(err, res) {
+ // wait for page change callback to happen before we return
+ // control to the client
+ me.onPageChangeCb = function() {
+ cb(err, res);
+ };
+ });
} else {
cb(new NotImplementedError(), null);
}
@@ -1257,7 +1276,13 @@ IOS.prototype.checkSuccess = function(err, res, cb) {
return true;
};
-IOS.prototype.closeSafariWindow = function(cb) {
+IOS.prototype.closeIPadWindow = function(cb) {
+ var me = this;
+ me.findAndAct('xpath', '//button[contains(@name, "Close tab for")]',
+ 0, 'tap', [], cb);
+};
+
+IOS.prototype.closeIPhoneWindow = function(cb) {
var me = this;
me.findAndAct('name', 'Pages', 0, 'tap', [], function(err, res) {
if (me.checkSuccess(err, res, cb)) {
View
28 test/functional/safari/safari.js
@@ -10,32 +10,8 @@ var desc = require("../../helpers/driverblock.js").describeForSafari()
, should = require('should');
-// todo: write window manipulation test for iphone version
-
-desc('safari ipad', function(h) {
- it('should be able to close tabs', function(done) {
- h.driver.frame(null, function() {
- h.driver.elementByTagName("window", function(err, win) {
- win.elementsByXPath("//button[contains(@name, 'Close tab for')]", function(err, els) {
- els.length.should.be.above(0);
- var closeTab = function(idx) {
- els[idx].click(function() {
- if (idx+1 === els.length) {
- done();
- } else {
- closeTab(idx+1);
- }
- });
- };
- closeTab(0);
- });
- });
- });
- });
-}, null, null, {device: 'iPad Simulator'});
-
-//var devices = ["iPhone", "iPad"];
-var devices = ["iPad", "iPhone"];
+var devices = ["iPhone", "iPad"];
+//var devices = ["iPad", "iPhone"];
_.each(devices, function(sim) {
Please sign in to comment.
Something went wrong with that request. Please try again.