Skip to content

Instantly share code, notes, and snippets.

@kyleian
Last active October 19, 2016 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleian/911e33e84e0e60074365e14149c34e09 to your computer and use it in GitHub Desktop.
Save kyleian/911e33e84e0e60074365e14149c34e09 to your computer and use it in GitHub Desktop.
for (i = 2; i <= listSize; i++) {
previousListItem = browser.element('.//*[@id=\''+listType+'List\']/'+listType+'-list-item['+(i-1)+']');
currentListItem = browser.element('.//*[@id=\''+listType+'List\']/'+listType+'-list-item['+i+']');
if(listType === 'user') {
previousListItemValue = previousListItem.getText('[data-automation-name="user-last-name"]');
currentListItemValue = currentListItem.getText('[data-automation-name="user-last-name"]');
}
else {
previousListItemValue = previousListItem.getText('[data-automation-name="'+listType+'-name"]');
currentListItemValue = currentListItem.getText('[data-automation-name="'+listType+'-name"]');
}
sortActualResult = util.strcmp(previousListItemValue.toUpperCase(), currentListItemValue.toUpperCase());
//Perform the below iff the previous and current user have the same last name
if(listType==='user' && sortActualResult === 0) {
//check if first names are the same
//@chimp - the below is where I typically yet intermittently fail - has occurred on different iterations of loop
//If the element didn't exist I'd expect to fail when calling toUpperCase() on undefined during my stringcompare.
previousListItemValue = previousListItem.getText('[data-automation-name="user-first-name"]');
currentListItemValue = currentListItem.getText('[data-automation-name="user-first-name"]');
sortActualResult = util.strcmp(previousListItemValue.toUpperCase(), currentListItemValue.toUpperCase());
if (sortActualResult === 0) {
//check if emails are the same
previousListItemValue = previousListItem.getText('[data-automation-name="user-email"]');
currentListItemValue = currentListItem.getText('[data-automation-name="user-email"]');
sortActualResult = util.strcmp(previousListItemValue.toUpperCase(), currentListItemValue.toUpperCase());
}
}
expect(sortActualResult).toEqual(sortExpectedResult, "Actual Result: " + previousListItemValue + "; Expected Result: " + currentListItemValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment