• Post Reply Bookmark Topic Watch Topic
  • New Topic

opening a Secured site (https) with user ID /password

 
Riju Mahna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My final aim is
1. To go to a password protected site
2. Provide my login ID/ password to enter
3.convert its contents in Excel format (feature provided by the site, we need to click a link) and
4. save the excel sheet in my system.


ALL THIS BY RUNNING A JAVA CLASS

Can somebody plzzz help out. :?: I can't make a head or tail out of it. ops:
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a couple of libraries that simulate a web browser in Java code. Apache HttpClient is somewhat low-level (on the HTTP level, as the name implies), while jWebUnit (on SourceForge) operates on a higher level. Both support password authentication. I'd go with jWebUnit (you'd need to write less code).
 
Riju Mahna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a LOT Ulf for your time and suggestion !!

BUT I am still not able to see the big picture. i have downloaded jWebUnit but could you please mention which part of API i should be looking at? or if you can share with me some sample code snippets for it..... ops:

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Essentially you're creating a "web conversation" of successive request and responses in code. So your code needs to contain instructions like "go to this URL", "click this link", "now enter this username/password into those form fields and submit the form", "now navigate to this other link", etc. The jWebUnit API (especially the WebTestCase class which you should extend) provides a lot of methods for doing this, and for getting at various parts of the pages that are returned from the server.

Ignore everything you read about testing and assertions. jWebUnit is a JUnit extension meant for testing web sites, but you'd be using it just for its capability of accessing web sites programmatically.

The home page has an example of how to use jWebUnit to log into a site using form-based authentication. The "Quick Start" section of the documentation has more code examples.
 
Riju Mahna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thousand Thanks again Ulf.... :!:

I have looked at the jUnit Quick start and the various methods it provides. The kink is that my manager insists I do it with HttpClient......
I know I am bugging you again, but I am still stuck.... :roll:

Can you suggest something similer to jUnit in HttpClient.?? :?:

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With HttpClient you need to write a lot more code yourself. But it has extensive documentation and sample code online; one of the samples is called "FormLoginDemo", which sounds like it might be a good start in your case.

This may also help (once you're logged into the site), but it's possible that the HttpClient API has changed since then.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!