cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alsoro...@apache.org
Subject cordova-plugin-contacts git commit: CB-11296: Appium: Better element clicking and session error handling
Date Tue, 24 May 2016 14:17:49 GMT
Repository: cordova-plugin-contacts
Updated Branches:
  refs/heads/master a65672617 -> 90b7114a2


CB-11296: Appium: Better element clicking and session error handling


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/90b7114a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/90b7114a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/90b7114a

Branch: refs/heads/master
Commit: 90b7114a2753d69cd6456bc5f93f41fb0917def2
Parents: a656726
Author: Alexander Sorokin <alexander.sorokin@akvelon.com>
Authored: Thu May 19 16:23:57 2016 +0300
Committer: Alexander Sorokin <alexander.sorokin@akvelon.com>
Committed: Tue May 24 17:17:31 2016 +0300

----------------------------------------------------------------------
 appium-tests/common/common.spec.js | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/90b7114a/appium-tests/common/common.spec.js
----------------------------------------------------------------------
diff --git a/appium-tests/common/common.spec.js b/appium-tests/common/common.spec.js
index ec19739..e2dbe51 100644
--- a/appium-tests/common/common.spec.js
+++ b/appium-tests/common/common.spec.js
@@ -41,6 +41,8 @@ describe('Contacts Android', function () {
     var driver;
     var webviewContext;
     var promiseCount = 0;
+    // going to set this to false if session is created successfully
+    var failedToStart = true;
 
     function getNextPromiseId() {
         return 'appium_promise_' + promiseCount++;
@@ -109,11 +111,16 @@ describe('Contacts Android', function () {
             .then(function () {
                 switch (PLATFORM) {
                     case 'ios':
-                        return wdHelper.tapElementByXPath(UNORM.nfd('//UIAStaticText[@label="'
+ name + '"]'), driver);
+                        return driver
+                            .waitForElementByXPath(UNORM.nfd('//UIAStaticText[@label="' +
name + '"]'), 20000)
+                            .elementByXPath(UNORM.nfd('//UIAStaticText[@label="' + name +
'"]'))
+                            .elementByXPath(UNORM.nfd('//UIAStaticText[@label="' + name +
'"]'));
                     case 'android':
-                        return driver.waitForElementByXPath('//android.widget.TextView[@text="'
+ name + '"]', MINUTE).click();
+                        return driver
+                            .waitForElementByXPath('//android.widget.TextView[@text="' +
name + '"]', MINUTE);
                 }
             })
+            .click()
             .context(webviewContext)
             .executeAsync(function (pID, cb) {
                 navigator._appiumPromises[pID].promise
@@ -218,19 +225,30 @@ describe('Contacts Android', function () {
             });
     }
 
+    function checkSession(done) {
+        if (failedToStart) {
+            fail('Failed to start a session');
+            done();
+        }
+    }
+
     it('contacts.ui.util configuring driver and starting a session', function (done) {
         getDriver()
-            .fail(fail)
+            .then(function () {
+                failedToStart = false;
+            }, fail)
             .done(done);
     }, 5 * MINUTE);
 
     describe('Picking contacts', function () {
         afterEach(function (done) {
+            checkSession(done);
             removeTestContacts()
                 .finally(done);
         }, MINUTE);
 
         it('contacts.ui.spec.1 Pick a contact', function (done) {
+            checkSession(done);
             var bday = new Date(1991, 1, 1);
             driver
                 .then(function () {
@@ -249,6 +267,7 @@ describe('Contacts Android', function () {
         }, 5 * MINUTE);
 
         it('contacts.ui.spec.2 Update an existing contact', function (done) {
+            checkSession(done);
             driver
                 .then(function () {
                     return addContact('Dooney', 'Evans');
@@ -272,6 +291,7 @@ describe('Contacts Android', function () {
         }, 10 * MINUTE);
 
         it('contacts.ui.spec.3 Create a contact with no name', function (done) {
+            checkSession(done);
             driver
                 .then(function () {
                     return addContact();
@@ -299,6 +319,7 @@ describe('Contacts Android', function () {
         }, 5 * MINUTE);
 
         it('contacts.ui.spec.4 Create a contact with Unicode characters in name', function
(done) {
+            checkSession(done);
             driver
                 .then(function () {
                     return addContact('Н€йромонах', 'ФеофаЊ');
@@ -316,6 +337,7 @@ describe('Contacts Android', function () {
     });
 
     it('contacts.ui.util Destroy the session', function (done) {
+        checkSession(done);
         driver
             .quit()
             .done(done);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message