From e778c551e020fc83cf760015248fa9bdf74cc6ed Mon Sep 17 00:00:00 2001 From: Isaac Murchie Date: Tue, 18 Nov 2014 10:24:12 -0800 Subject: [PATCH] Add test for clearing password --- submodules/ApiDemos | 2 +- .../android/apidemos/clear-specs.js | 136 +++++++++--------- 2 files changed, 65 insertions(+), 73 deletions(-) diff --git a/submodules/ApiDemos b/submodules/ApiDemos index 6f572524a..78a14d29a 160000 --- a/submodules/ApiDemos +++ b/submodules/ApiDemos @@ -1 +1 @@ -Subproject commit 6f572524a8b3444b1c6cf4ec72a096b994517bc6 +Subproject commit 78a14d29a92c78f242104b78f1eeb832c310e523 diff --git a/test/functional/android/apidemos/clear-specs.js b/test/functional/android/apidemos/clear-specs.js index d2713ecda..87404ca7d 100644 --- a/test/functional/android/apidemos/clear-specs.js +++ b/test/functional/android/apidemos/clear-specs.js @@ -10,125 +10,117 @@ describe("apidemos - clear", function () { var driver; var _desired = _.defaults({ app: getAppPath('ApiDemos'), - appActivity: '.view.Controls1', + appActivity: '.view.TableLayout10', newCommandTimeout: 90, language: 'en', locale: 'en_US' }, desired); setup(this, _desired).then(function (d) { driver = d; }); - describe('clear', function () { + describe('clear textfield', function () { it('should clear an empty field with hint', function (done) { + var el; driver .waitForElementByClassName('android.widget.EditText') - .click() - .sleep(1000) + .then(function (_el) { + el = _el; + return el; + }) .clear() - .sleep(1000) - .elementByClassName('android.widget.EditText') - .text().should.become('hint text') + .sleep(100) + .then(function () { + return el; + }) + .text().should.become('enter username') .nodeify(done); }); it('should clear a field with hint', function (done) { + var el; driver .waitForElementByClassName('android.widget.EditText') - .click() + .then(function (_el) { + el = _el; + return el; + }) .sendKeys('Are you looking at me!') - .sleep(1000) + .sleep(100) .clear() - .sleep(1000) - .elementByClassName('android.widget.EditText') - .text().should.become('hint text') + .sleep(100) + .then(function () { + return el; + }) + .text().should.become('enter username') + .nodeify(done); + }); + + }); + + describe('clear password textfield', function () { + it('should clear', function (done) { + var el; + driver + .waitForElementsByClassName('android.widget.EditText') + .then(function (els) { + el = els[1]; + return el; + }) + .sendKeys('super secure password') + .sleep(100) + .then(function () { + el.text().should.become('super secure password'); + return el; + }) + .clear() + .sleep(100) + .then(function () { + return el; + }) + .text().should.become('') .nodeify(done); }); }); describe('hideKeyboard', function () { - - it('should hide the keyboard using the default strategy', function (done) { + var testHideKeyboard = function (args, done) { driver .waitForElementByClassName('android.widget.EditText') .click() - .sleep(1000) - .hideKeyboard() - .sleep(1000) + .sleep(500) + .hideKeyboard(args) + .sleep(500) .elementByClassName('android.widget.EditText') - .should.eventually.exist + .should.eventually.exist .nodeify(done); + }; + + it('should hide the keyboard using the default strategy', function (done) { + testHideKeyboard(null, done); }); it('should hide the keyboard using the "Done" key', function (done) { - driver - .waitForElementByClassName('android.widget.EditText') - .click() - .sleep(1000) - .hideKeyboard('Done') - .sleep(1000) - .elementByClassName('android.widget.EditText') - .should.eventually.exist - .nodeify(done); + testHideKeyboard('Done', done); }); it('should hide the keyboard using the "press" strategy and "Done" key', function (done) { - driver - .waitForElementByClassName('android.widget.EditText') - .click() - .sleep(1000) - .hideKeyboard({strategy:'press', key: 'Done'}) - .sleep(1000) - .elementByClassName('android.widget.EditText') - .should.eventually.exist - .nodeify(done); + testHideKeyboard({strategy:'press', key: 'Done'}, done); }); it('should hide the keyboard using the "pressKey" strategy and "Done" key', function (done) { - driver - .waitForElementByClassName('android.widget.EditText') - .click() - .sleep(1000) - .hideKeyboard({strategy:'pressKey', key: 'Done'}) - .sleep(1000) - .elementByClassName('android.widget.EditText') - .should.eventually.exist - .nodeify(done); + testHideKeyboard({strategy:'pressKey', key: 'Done'}, done); }); it('should hide the keyboard using the "pressKey" strategy and "Done" key', function (done) { - driver - .waitForElementByClassName('android.widget.EditText') - .click() - .sleep(1000) - .hideKeyboard({strategy:'swipeDown'}) - .sleep(1000) - .elementByClassName('android.widget.EditText') - .should.eventually.exist - .nodeify(done); + testHideKeyboard({strategy:'swipeDown'}, done); }); it('should hide the keyboard using the "tapOutside" strategy', function (done) { - driver - .waitForElementByClassName('android.widget.EditText') - .click() - .sleep(1000) - .hideKeyboard({strategy:'tapOutside'}) - .sleep(1000) - .elementByClassName('android.widget.EditText') - .should.eventually.exist - .nodeify(done); + testHideKeyboard({strategy:'tapOutside'}, done); }); it('should hide the keyboard using the "tapOut" strategy', function (done) { - driver - .waitForElementByClassName('android.widget.EditText') - .click() - .sleep(1000) - .hideKeyboard({strategy:'tapOut'}) - .sleep(1000) - .elementByClassName('android.widget.EditText') - .should.eventually.exist - .nodeify(done); + testHideKeyboard({strategy:'tapOut'}, done); }); }); });