0

I am new to using Phantom.js . I am trying to get the response of a click event via Phantom.js. But i am unable to get. i just want to know how one can get the response of any event like click, submit or other.

I tried to get the response from google page as enter some value on the google text box and than click on search i just want to print the response coming from google for that particular search. Or some example that print the response of any click button via its id or class.

Below is my code:-

var page = require('webpage').create();
page.open('http://www.google.com', function() {
console.log('Running of phantom.js')
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
page.evaluate(function(){
$('#lst-ib').val('hello');
$("form[name='f']").submit(); // i want to print this response
//console.log(page.content);
})
    phantom.exit();
})
}); 

Any help would be appreciated.

Thanks!

Parveen yadav
  • 2,252
  • 1
  • 21
  • 35
  • What do you mean by "response"? Server headers? Search results? – Vaviloff Sep 15 '16 at 10:16
  • @Vaviloff thanks for fast reply and i mean search result. – Parveen yadav Sep 15 '16 at 10:18
  • You would have to [wait for](https://github.com/ariya/phantomjs/blob/master/examples/waitfor.js) the search results to appear. If you're starting to use PhantomJS, a Google page is the worst page you can start, because it behaves differently depending on the browser (Desktop vs. Mobile vs. PhantomJS). Try some other page if this is only for learning. – Artjom B. Sep 15 '16 at 17:07

0 Answers0