wood burning stoves*
The moose likes Testing and the fly likes button.click() not working ,ie HTTPUNIT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "button.click() not working ,ie HTTPUNIT" Watch "button.click() not working ,ie HTTPUNIT" New topic
Author

button.click() not working ,ie HTTPUNIT

bhimi reddy
Greenhorn

Joined: Jun 03, 2004
Posts: 6
Hi,
I am bhimi... I am facing problems with "httpunit", I would like to know how to click the "continue" button in Compose Text Message page of www.mail.yahoo.com. with my destination mobile phone number and text message as setting parameters....(I could set these parameters but could not click the "Continue" button).

My user id is "batman2004_2004"
pass- word is "testing"

1. I am logging into mail.yahoo.com with a java testcase using this Httpunit .
2.Next i am entering into the "compose text message page",by clicking "compose text msg" button which lies next to INBOX, COMPOSE buttons with my java program...
3.Next i could enter mobile phone number and text message,but the problem is IT IS NOT CLICKING THE "CONTINUE" BUTTON through my java program...

please let me know ...

Thanks in advance,

Regards,
Bhimi...
My code snippet is as follows....


WebResponse wr = wc.getResponse( "http://mail.yahoo.com");


//get the login form

WebForm form = wr.getFormWithName("login_form");

form.setParameter(".done", "http://mail.yahoo.com");
form.setParameter("login", "batman2004_2004");
form.setParameter("passwd", "testing");
form.submit();
WebResponse wr1 = wc.getResponse( "http://mail.yahoo.com");



WebResponse wr2 = wc.getResponse(ymCompose);
// this is compose SMS page...


WebForm form2 = wr2.getFormWithName("Compose");

form2.setParameter("To","00497953453520");
form2.setParameter("Body", "hi, how r u.");

Button buttons = form4.getButtonWithID("sendtop");
buttons.click();

WebResponse wr4 = wc.getCurrentPage();

I COULD NOT SUCCEED... LATER TRIED THESE STEPS ALSO


WebForm form2 = wr2.getFormWithName("Compose");

form2.setParameter("To","+4979534535203");
form2.setParameter("Body", "hi, how r u.");

SubmitButton submitbutton = form4.getSubmitButton("sendtop");
submitbutton.click();

or also in this way

SubmitButton submitbutton = form4.getSubmitButton("sendtop");
form4.submit(submitbutton);
WebResponse wr4 = wc.getCurrentPage();


PLEASE HELP ME ..............

thanks & regards,
bhimi.
[ September 15, 2004: Message edited by: bhimi reddy ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
It looks like Yahoo! is relying very much on JavaScript behind that button and the browser-specific parts of the calcStats() function would be my prime suspects. You could try to make your HttpUnit script emulate Netscape, for example (by sending a suitable "User-Agent" header), and see whether that helps.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Oops. They're using a more reliable way of detecting the browser, which kind of invalidates the "emulation" approach:
bhimi reddy
Greenhorn

Joined: Jun 03, 2004
Posts: 6
ya, i have tried with that user agent too, but then also same problem with button click.

any help would be appreciated....
bhimi reddy
Greenhorn

Joined: Jun 03, 2004
Posts: 6

[ September 17, 2004: Message edited by: bhimi reddy ]
bhimi reddy
Greenhorn

Joined: Jun 03, 2004
Posts: 6
Originally posted by bhimi reddy:
ya, i have tried with ""user agent"" too. my snippet is as follows..

cp.setApplicationVersion("Mozilla/5.0(compatible; MSIE 6.0; Windows XP)");
cp.setPlatform("Win32");
cp.setApplicationName("Microsoft Internet Explorer");

everything is working fine, except that button click.

Any hepl would be appreciated....


Hi there,
It seem's some stranger has changed the password. Anyway you can get that "continue" button in this uk link. "http://login.europe.yahoo.com/config/mail?.intl=uk"

plz get registered, as someone is going on changing my password which i had kept visible to all, so that u can login directly and save some registration time. But I guess there is a mischief in our forums...

ur help ll be appreciated...
bhimi reddy
Greenhorn

Joined: Jun 03, 2004
Posts: 6

[ September 17, 2004: Message edited by: bhimi reddy ]
 
 
subject: button.click() not working ,ie HTTPUNIT
 
Similar Threads
HttpUnit
Button click in HttpUnit
jsp httpunit new window question
sensing submit in servlet
ArrayIndexOutOfBoundsException