jQuery in Action, 2nd edition*
The moose likes Testing and the fly likes there is a form, but unable to test the login page. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "there is a form, but unable to test the login page." Watch "there is a form, but unable to test the login page." New topic
Author

there is a form, but unable to test the login page.

ambati prashanth
Greenhorn

Joined: Aug 07, 2005
Posts: 20
Hai,
Thanks for your replies for my previous mail. Now I written small code to submit a "yahoo mail's" login form. The problem now is,the form is inside a table and they created some inner tables in one of the inner table they given username, password and submit button. when i set the values like shown below it is generating some error.

import junit.framework.TestCase;
import com.meterware.httpunit.*;

public class testGoodLogin extends TestCase {

public void testGoodLogin1() throws Exception {
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest(
"http://www.mail.yahoo.com" );

WebResponse response = conversation.getResponse( request );
WebForm loginForm = response.getForms()[0];
request = loginForm.getRequest();

/* it unable to set the values through below instructions.
*/
loginForm.setParameter( "login", "ambati_prashanth" );
loginForm.setParameter( "passwd", "justdoit" );
response =loginForm.submit();
System.out.println("Title of the page is "+ response.getTitle());

}
}


the source code for yahoo mail page is:


<form method=post action="https://login.yahoo.com/config/login?" autocomplete=off name=login_form><input type=hidden name=.tries value="1">



<!------------------ BEGIN login form ------------------->
<tr>
<td>
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<td align="right" nowrap class="bodywhite">Yahoo! ID:</td>
<td align="right"><input name="login" style="width:130px"

value=""></td>
</tr>
<tr>
<td align="right" nowrap class="bodywhite">Password:</td>
<td align="right"><input name="passwd" style="width:130px" value="" type="password"></td>
</tr>
<tr>
<td colspan="2" nowrap align="right" class=bodywhite><input type="checkbox" name=".persistent" value="y">Remember my ID on this computer<br><br></td>
</tr>
<tr>
<td colspan="2" align="right"><input name=".save" type="submit" value="Sign In" class=buttonwhite></td>
</tr>
</table>
</td>
</tr>
<!------------------ END login form ----------------------->


Please help me.
Regards
Prashanth.A
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41634
    
  55
What exactly is "some error"?


Ping & DNS - my free Android networking tools app
ambati prashanth
Greenhorn

Joined: Aug 07, 2005
Posts: 20
I am unable to set the values to the text box and password field. because when i executed that code it is showing error at that line mentioned itself.

if you still not get problem then plese try to execute and see, you can understand what the error is.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41634
    
  55
Are you suggesting I should download and install JUnit and HttpUnit, and get a Yahoo Mail account just so I can reproduce your problem, when you have already done that? That's a bit too much to ask, and it wouldn't do any good for all the others who read this, and who also would like to help you, but can't because you don't provide enough information about the problem.

Just post what kind of error it is -a stacktrace would be fine-, and we'll take it from there.
ambati prashanth
Greenhorn

Joined: Aug 07, 2005
Posts: 20
I am sorry. You totally missunderstand me and my problem.my problem is already explained and if you are not able to get then i requested to run that program.

the "www.mail.yahoo.com" page contain a form inside a row of a table and one more roe acontain one more table and so on. in one table there is a textbox which takes user name and one password which takes password. I tried to set the values to those 2 fields through my program.I hope there is no mistake, but still it is not accepting the values.Please find what is the mistake i did in my code.

once again I am sorry if any body misunderstand me and my way of expression.

Thanks and Regards
Prashanth.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41634
    
  55
On first glance I'd say it should work the way you have it.


I tried to set the values to those 2 fields through my program.


Once again: what does this mean? Do the setParameter methods throw an exception? What is the response that is returned? Without knowing this we can't guess what might be going on.

I just notice that the page is submitted via HTTPS, not HTTP. There are a few extra steps you need to do before HttpUnit can work over HTTPS, although those seem to deal with setting up the server. I'm not sure if something needs to be set up for HttpUnit to use SSL on the client.
[ August 10, 2005: Message edited by: Ulf Dittmer ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by ambati prashanth:
still it is not accepting the values.


What does that mean? How do you know that it isn't accepting them?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
ambati prashanth
Greenhorn

Joined: Aug 07, 2005
Posts: 20
Originally posted by Ilja Preuss:


What does that mean? How do you know that it isn't accepting them?


Because when i run that program it is showing some errors.when I click the error it is pointing the instruction where i showned the confussion symbol.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Then tell us the details about the errors you get. If nothing else, simply copy and paste them here. Otherwise it is unlikely that someone can help you effectively.

See also http://faq.javaranch.com/view?TellTheDetails
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: there is a form, but unable to test the login page.