Skip to content

Instantly share code, notes, and snippets.

@kyleian
Last active October 27, 2016 12:34
Show Gist options
  • Save kyleian/cfb6c66351e54d5a7225121c8cc4e99e to your computer and use it in GitHub Desktop.
Save kyleian/cfb6c66351e54d5a7225121c8cc4e99e to your computer and use it in GitHub Desktop.
this.Given(/^I have (selected|deselected) (.*)$/, function (selectAction, location) {
var locations;
var treeElements;
var expectedLocationName = null;
locations=location.split(","); //Reassess FF to pass in table later
browser.waitForVisible('[ng-if="options.searchShow"]',5000);
console.log(locations);
for(var i=0;i<locations.length;i++) {
expectedLocationName = locations[i].toString();
browser.clearElement('[ng-if="options.searchShow"]');
browser.click('[ng-if="options.searchShow"]').keys(expectedLocationName);
browser.pause(1000); //wait for search to complete
//grab any leaves of remaining visible tree after search based on class; selected elements have class 'tree-label tree-selected'
treeElements = browser.elements('.tree-label', 5000);
console.log(treeElements['value']);
treeElements['value'].map(function(singleTreeElement) {
var actualLocationName = browser.elementIdText(singleTreeElement.ELEMENT).value;
if (actualLocationName === expectedLocationName) {
console.log("actual location found on page '" + actualLocationName + "' matched expected value '" + expectedLocationName + "'");
try {
browser.elementIdClick(singleTreeElement.ELEMENT); //@chromedriver - Fails on 'already clicked' element ( class="tree-label tree-selected" )
}catch(err){
console.log("Before logging error:");
console.log(err);
console.assert(!err,"I definitely died"); //Do this to ensure we kill step
}
console.log("Successfully clicked");
}
return;
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment