Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. this.Given(/^I have (selected|deselected) (.*)$/, function (selectAction, location) {
  2. var locations;
  3. var treeElements;
  4. var expectedLocationName = null;
  5. locations=location.split(","); //Reassess FF to pass in table later
  6.  
  7. browser.waitForVisible('[ng-if="options.searchShow"]',5000);
  8. console.log(locations);
  9.  
  10. for(var i=0;i<locations.length;i++) {
  11.  
  12. expectedLocationName = locations[i].toString();
  13.  
  14. browser.clearElement('[ng-if="options.searchShow"]');
  15. browser.click('[ng-if="options.searchShow"]').keys(expectedLocationName);
  16. browser.pause(1000); //wait for search to complete
  17.  
  18. //grab any leaves of remaining visible tree after search based on class; selected elements have class 'tree-label tree-selected'
  19. treeElements = browser.elements('.tree-label', 5000);
  20. console.log(treeElements['value']);
  21.  
  22. treeElements['value'].map(function(singleTreeElement) {
  23.  
  24. var actualLocationName = browser.elementIdText(singleTreeElement.ELEMENT).value;
  25. if (actualLocationName === expectedLocationName) {
  26. console.log("actual location found on page '" + actualLocationName + "' matched expected value '" + expectedLocationName + "'");
  27. try {
  28. browser.elementIdClick(singleTreeElement.ELEMENT); //@Wdio - Fails on 'already clicked' element ( class="tree-label tree-selected" )
  29. }catch(err){
  30. console.log("Before logging error:");
  31. console.log(err);
  32. console.assert(!err,"I definitely died"); //Do this to ensure we kill step
  33. }
  34. console.log("Successfully clicked");
  35. }
  36. return;
  37. });
  38. }
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement