Merge pull request #2222 from imurchie/isaac-contexts

Fix setWindow for Android
This commit is contained in:
Jonathan Lipps
2014-03-31 12:21:22 -07:00
3 changed files with 79 additions and 5 deletions
+4 -1
View File
@@ -3,4 +3,7 @@
process.env.DEVICE = process.env.DEVICE || "android";
var androidWebviewTests = require('../../helpers/android-webview');
describe('android - web_view -', androidWebviewTests);
describe('android - web_view - contexts -', androidWebviewTests.contexts);
// TODO: remove in Appium 1.0
describe('android - web_view - windows -', androidWebviewTests.windows);
+71 -3
View File
@@ -11,7 +11,7 @@ var desired = {
'app-activity': '.HomeScreenActivity'
};
module.exports = function () {
module.exports.contexts = function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
@@ -52,10 +52,10 @@ module.exports = function () {
});
// skip until Selendroid implements context methods
it('should raise NoSuchContext error for non-existent context @skip-selendroid-all', function (done) {
it('should raise NoSuchContext (status: 35) @skip-selendroid-all', function (done) {
driver
.context('WEBVIEW_42')
.should.be.rejectedWith('NoSuchContext')
.should.be.rejectedWith(/status: 35/)
.nodeify(done);
});
@@ -91,3 +91,71 @@ module.exports = function () {
.nodeify(done);
});
};
// TODO: remove in Appium 1.0
module.exports.windows = function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
beforeEach(function (done) {
driver
.waitForElementByName('buttonStartWebviewCD').click()
.sleep(500)
.window('WEBVIEW')
.nodeify(done);
});
if (env.FAST_TESTS) {
afterEach(function (done) {
driver
.window('NATIVE_APP')
.then(function () {
if (env.DEVICE === "selendroid") {
return driver.elementByIdOrNull('goBack');
} else {
return driver.elementByTagNameOrNull('button');
}
})
.then(function (el) {
if (el) return el.click().sleep(1000);
}).nodeify(done);
});
}
it('should be web view', function (done) {
// todo: add some sort of check here
done();
});
it('should find and click an element', function (done) {
driver
.elementByCssSelector('input[type=submit]').click()
.waitForElementByXPath("//h1[contains(., 'This is my way')]")
.nodeify(done);
});
// selendroid test app is busted
it('should clear input @skip-selendroid-all', function (done) {
driver
.elementById('name_input').click().clear().getValue().should.become("")
.nodeify(done);
});
// selendroid test app is busted
it('should find and enter key sequence in input @skip-selendroid-all', function (done) {
driver
.elementById('name_input').clear()
.type("Mathieu").getValue().should.become("Mathieu")
.nodeify(done);
});
it('should be able to handle selendroid special keys @skip-android-all', function (done) {
driver.keys('\uE102').nodeify(done);
});
it('should get web source', function (done) {
driver
.source().should.eventually.include("<title>Say Hello Demo<")
.nodeify(done);
});
};