query on extracting headings from google page

Hi Lakshay,

 

Could you please guide me on how to extract the headings from google page after I have searched a particular string for e.g “mobile phones” from www.google.com.<Screen shot is attached

query on extracting headings from google page

>

 

 

 

I have attached a screen shot above. What I mean to say is – how can I extract the headings(via getText() for e.g.) like “mobile phone –wikipedia the free encyclopedia”, “Mobiles:Mobile Phones with Lowest Prices..” etc .Do I have to go inside each and every page and do getTitle()? I tried checking the Xpath() but it was  pretty long with no concrete attributes .Please suggest. I have also attached the code below whichI am using  – please see if it is correct.

 

 

Thanks

Anupam

 

 

Add Comment
  • 2 Answer(s)

    hi anupam

    you can try this  a lil hardcoded but will work

     

     

    Vice Professor Answered on August 12, 2014.
    Add Comment

    HI Ankit,

    Thanks for your suggestion !! Its working fine for me :). Initially I tried only the xpath which you have used in your code – it didnt worked. However when I added the implicit wait – all the headline strings got printed successfully.

    Thanks again.
    Anupam

    Train Answered on August 13, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.