Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 956c76b

Browse files
committed
CB-11166 Appium tests: Added a check for contact's birthday
1 parent 959c398 commit 956c76b

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

appium-tests/common/common.spec.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,20 @@ describe('Contacts Android', function () {
7171
});
7272
}
7373

74-
function addContact(firstName, lastName) {
74+
function addContact(firstName, lastName, bday) {
75+
var bdayString = bday ? bday.toDateString() : undefined;
7576
var contactName = contactsHelper.getContactName(firstName, lastName);
7677
return driver
7778
.context(webviewContext)
7879
.setAsyncScriptTimeout(MINUTE)
79-
.executeAsync(function(contactname, callback) {
80+
.executeAsync(function(contactname, bday, callback) {
8081
navigator.contacts.create({
8182
'displayName': contactname.formatted,
8283
'name': contactname,
83-
'note': 'DeleteMe'
84+
'note': 'DeleteMe',
85+
'birthday': new Date(bday)
8486
}).save(callback, callback);
85-
}, [contactName])
87+
}, [contactName, bdayString])
8688
.then(function(result) {
8789
if (result && result.hasOwnProperty('code')) {
8890
throw result;
@@ -107,16 +109,18 @@ describe('Contacts Android', function () {
107109
.then(function () {
108110
switch (PLATFORM) {
109111
case 'ios':
110-
return driver.waitForElementByXPath(UNORM.nfd('//UIAStaticText[@label="' + name + '"]'), MINUTE);
112+
return wdHelper.tapElementByXPath(UNORM.nfd('//UIAStaticText[@label="' + name + '"]'), driver);
111113
case 'android':
112-
return driver.waitForElementByXPath('//android.widget.TextView[@text="' + name + '"]', MINUTE);
114+
return driver.waitForElementByXPath('//android.widget.TextView[@text="' + name + '"]', MINUTE).click();
113115
}
114116
})
115-
.click()
116117
.context(webviewContext)
117118
.executeAsync(function (pID, cb) {
118119
navigator._appiumPromises[pID].promise
119120
.then(function (contact) {
121+
// for some reason Appium cannot get Date object
122+
// let's make birthday a string then
123+
contact.birthday = contact.birthday.toDateString();
120124
cb(contact);
121125
}, function (err) {
122126
cb('ERROR: ' + err);
@@ -133,7 +137,7 @@ describe('Contacts Android', function () {
133137
function renameContact(oldName, newGivenName, newFamilyName) {
134138
return driver
135139
.context(webviewContext)
136-
.setAsyncScriptTimeout(4 * MINUTE)
140+
.setAsyncScriptTimeout(7 * MINUTE)
137141
.executeAsync(function (oldname, newgivenname, newfamilyname, callback) {
138142
var obj = new ContactFindOptions();
139143
obj.filter = oldname;
@@ -227,16 +231,18 @@ describe('Contacts Android', function () {
227231
}, MINUTE);
228232

229233
it('contacts.ui.spec.1 Pick a contact', function (done) {
234+
var bday = new Date(1991, 1, 1);
230235
driver
231236
.then(function () {
232-
return addContact('Test', 'Contact');
237+
return addContact('Test', 'Contact', bday);
233238
})
234239
.then(function () {
235240
return pickContact('Test Contact');
236241
})
237242
.then(function (contact) {
238243
expect(contact.name.givenName).toBe('Test');
239244
expect(contact.name.familyName).toBe('Contact');
245+
expect(contact.birthday).toBe(bday.toDateString());
240246
})
241247
.fail(saveScreenshotAndFail)
242248
.done(done);
@@ -263,7 +269,7 @@ describe('Contacts Android', function () {
263269
})
264270
.fail(saveScreenshotAndFail)
265271
.done(done);
266-
}, 6 * MINUTE);
272+
}, 10 * MINUTE);
267273

268274
it('contacts.ui.spec.3 Create a contact with no name', function (done) {
269275
driver

0 commit comments

Comments
 (0)