0

In PhontomJs I want to Page automate this particular page https://exclusions.oig.hhs.gov/ I can able to open this page and I can able to enter the values in the fields and after clicking this page I'm getting multiple search results having multiple results in a table i need to go through each and every link(in this page the href's are in the form of _dopost methods I'm not able to get exact links, so I must & should to click the particular anchor element) of the displayed page and do some comparison operation in next child pages.I must and should able to click all the links in the search result

Please help me...!!! Thanks in advance

  • What is your actual problem? You can't find out how to get all the link elements and then call .click on them? Or do you have another problem? – Bob Brinks Aug 17 '16 at 17:45
  • Actual problem that I'm facing is after getting into second page(search results Page).I'm getting multiple records I need to go through each and every link one after other and take the screenshots of those.. I'm confused how to do it please help me by provide code – yelchurisaimanoj Aug 17 '16 at 17:55
  • For more information you can just visit the url https://exclusions.oig.hhs.gov/ and in search fields type: LastName :Smith and click the search ... you will get some set of results.. now i need to go through each and every link & take screenshoot – yelchurisaimanoj Aug 17 '16 at 17:59

1 Answers1

0

Should be something like (assuming you use jQuery):

page.open('https://exclusions.oig.hhs.gov/ ', function(status) {

  //Do the search

  var links = page.evaluate(function(s) {
    //Refine this selector so you only get the links you want
    return document.querySelector("a");
  });

  //loop through links
  $.forEach(links, function(link){
      $(link).click();
      //Do stuff on the page
  })
});
Bob Brinks
  • 1,372
  • 1
  • 10
  • 19