wood burning stoves 2.0*
The moose likes Testing and the fly likes Httpunit button.click() not working 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 "Httpunit button.click() not working" Watch "Httpunit button.click() not working" New topic
Author

Httpunit button.click() not working

bala nagaraj
Greenhorn

Joined: Jan 06, 2004
Posts: 2
Hi below is my code to click a button using httpunit's button.click() to request on click java script and submit the page to get next page. It's not working... Any ideas?
WebResponse aeWR = webConversation.getCurrentPage();
WebForm aeWF = aeWR.getFormWithName("f1");
Button[] aeBTN = aeWF.getButtons();
aeBTN[0].click();
aeWR = webConversation.getCurrentPage(); --> Still old page??
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
So there are no stack traces?
Maybe the first button in the array is not the one you think it is?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
The tricky bit here is probably the JavaScript. Although recent versions of HTTPUnit support JavaScript, they need the rhino.jar in the test classpath (did you see a messsage like "rhino.jar not found, JavaScript disabled" when the test started?) and not all JavaScript makes sense (HTTPUnit is not actually a browser!).
Can you show us the web page you are testing, and whetever JavaScript code is supposed to be executed when you click the button?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Christian Hargraves
Ranch Hand

Joined: Jul 01, 2003
Posts: 42
Also if clicking that button opens a new window, then the latest response could be obtained by the getOpenWindows()(?) function.
rama vijay
Greenhorn

Joined: Apr 15, 2004
Posts: 1
Hi
clicking a button using httpunit's button.click()is not working... Any ideas?
WebResponse aeWR = webConversation.getCurrentPage();
WebForm aeWF = aeWR.getFormWithName("f1");
Button[] aeBTN = aeWF.getButtons();
aeBTN[0].click();
aeWR = webConversation.getCurrentPage();
[ April 15, 2004: Message edited by: rama vijay ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Again, what do you mean by "is not working"?
akkina sathish
Greenhorn

Joined: Apr 19, 2006
Posts: 24
Hi
I am also facing same problem. After button.click() (which contains javascript to get new page) still i am getting oldPage through this WC.getCurrentPage().

(Is it really possible possible to get new page by button click in HTTPunit tests)

AnyOne can Please help me.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Apparently the JavaScript URL change stuff your buttons are doing is not supported by HttpUnit/Rhino. I'd take this up on the HttpUnit mailing list where the HttpUnit developers might be able to give more advise.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Httpunit button.click() not working
 
Similar Threads
calling previous page whout refreshing it.
Calling a backing bean method from onClick?
My Cancel button is not working in struts1.2
Button click in HttpUnit
HTTPUnit Button Clicks and javascript functions