Allow multiple calls to get contexts in iOS

This commit is contained in:
Isaac Murchie
2014-05-01 11:26:57 -07:00
parent 1c4fa7c5ba
commit 488789c326
3 changed files with 96 additions and 3 deletions

View File

@@ -31,6 +31,10 @@ iOSHybrid.listWebFrames = function (cb, exitCb) {
var onDone = function (res) {
this.processingRemoteCmd = false;
isDone = true;
if (Array.isArray(res) && res.length === 0) {
// we have no web frames, so disconnect from the remote debugger
this.stopRemote();
}
cb(res);
}.bind(this);

View File

@@ -0,0 +1,67 @@
"use strict";
var setup = require("../../common/setup-base"),
desired = require('./desired'),
unorm = require('unorm');
describe('testapp - context methods', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('getting list multiple times should not crash appium', function (done) {
driver
.contexts().should.eventually.have.length(1)
.contexts().should.eventually.have.length(1)
.contexts().should.eventually.have.length(1)
.contexts().should.eventually.have.length(1)
.contexts().should.eventually.have.length(1)
.contexts().should.eventually.have.length(1)
.contexts().should.eventually.have.length(1)
.contexts().should.eventually.have.length(1)
.nodeify(done);
});
it('setting context to \'null\' should work', function (done) {
driver.contexts().then(function (ctxs) {
ctxs.length.should.be.equal(1);
return ctxs[0];
}).then(function (ctx) {
return driver.context(ctx);
})
.context(null)
.nodeify(done);
});
it('setting context to \'NATIVE_APP\' should work', function (done) {
driver.contexts().then(function (ctxs) {
ctxs.length.should.be.above(0);
return ctxs[0];
}).then(function (ctx) {
return driver.context(ctx);
})
.context('NATIVE_APP')
.nodeify(done);
});
it('setting context to non-existent context should return \'NoSuchContext\' (status: 35)', function (done) {
driver
.context("WEBVIEW_42")
.should.be.rejectedWith(/status: 35/)
.nodeify(done);
});
});
describe('testapp - window methods', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
it('getting list multiple times should not crash appium', function (done) {
driver
.windowHandles().should.eventually.have.length(0)
.windowHandles().should.eventually.have.length(0)
.windowHandles().should.eventually.have.length(0)
.windowHandles().should.eventually.have.length(0)
.windowHandles().should.eventually.have.length(0)
.windowHandles().should.eventually.have.length(0)
.windowHandles().should.eventually.have.length(0)
.nodeify(done);
});
});

View File

@@ -25,6 +25,17 @@ describe('webview - webview -', function () {
.contexts().should.eventually.have.length.above(0)
.nodeify(done);
});
it('getting list multiple times should not crash appium', function (done) {
driver
.contexts().should.eventually.have.length.above(1)
.contexts().should.eventually.have.length.above(1)
.contexts().should.eventually.have.length.above(1)
.contexts().should.eventually.have.length.above(1)
.contexts().should.eventually.have.length.above(1)
.contexts().should.eventually.have.length.above(1)
.contexts().should.eventually.have.length.above(1)
.nodeify(done);
});
it('contexts should be strings', function (done) {
driver.contexts().then(function (ctxs) {
ctxs.length.should.be.above(0);
@@ -46,7 +57,7 @@ describe('webview - webview -', function () {
driver
.context("WEBVIEW_1")
.get("http://google.com")
.sleep(500)
.sleep(1000)
.title()
.should.eventually.equal("Google")
.nodeify(done);
@@ -55,7 +66,7 @@ describe('webview - webview -', function () {
driver
.context("WEBVIEW")
.get("http://google.com")
.sleep(500)
.sleep(1000)
.title()
.should.eventually.equal("Google")
.nodeify(done);
@@ -99,7 +110,7 @@ describe('webview - webview -', function () {
.context("NATIVE_APP")
.context("WEBVIEW_1")
.get("https://saucelabs.com/home")
.sleep(500)
.sleep(1000)
.title()
.should.eventually.equal("Sauce Labs: Selenium Testing, Mobile Testing, JS Unit Testing and More")
.nodeify(done);
@@ -127,6 +138,17 @@ describe('webview - webview -', function () {
.windowHandles().should.eventually.have.length.above(0)
.nodeify(done);
});
it('getting list multiple times should not crash appium', function (done) {
driver
.windowHandles().should.eventually.have.length.above(0)
.windowHandles().should.eventually.have.length.above(0)
.windowHandles().should.eventually.have.length.above(0)
.windowHandles().should.eventually.have.length.above(0)
.windowHandles().should.eventually.have.length.above(0)
.windowHandles().should.eventually.have.length.above(0)
.windowHandles().should.eventually.have.length.above(0)
.nodeify(done);
});
it('window handles should be strings', function (done) {
driver.windowHandles().then(function (handles) {
handles.length.should.be.above(0);