File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes HttpUnit , Javascript Errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "HttpUnit , Javascript Errors" Watch "HttpUnit , Javascript Errors" New topic
Author

HttpUnit , Javascript Errors

Venkata Kiran
Ranch Hand

Joined: Sep 06, 2005
Posts: 30
Hai All,
I am testing a website using HttpUnit.
The website uses Javascript Redirects instead of plain Html Links.
How can I test these Links using HttpUnit.
Thanking You .
[ October 19, 2005: Message edited by: Kiran sss ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
What happens when you test them with HttpUnit? Does it not work? If not, in what way, any error messages?

By the way, your display name does not conform to the JavaRanch policy. You should correct it.


Ping & DNS - updated with new look and Ping home screen widget
Venkata Kiran
Ranch Hand

Joined: Sep 06, 2005
Posts: 30
The link click is not working for the Javascript Redirects.
No error messages ,but I am not even able to go to the next page.
The same code is working with normal Hyperlinks.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Could you post the JavaScript snippet(s) that are not working?
I assume you've already tried to compare what functions you use to the list of supported functions?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Venkata Kiran
Ranch Hand

Joined: Sep 06, 2005
Posts: 30
The page contains 3 frames in which the Hyperlinks are present.

The Html code of the two links which call the JavaScript function are:

<td ID="menu_cell_search" class="MenuTD" align="center"><a ID="menu_link_1" onclicq="menuGoUrl('select_search_fr', parent.index_main);return false" href="#" target="index_main">Search</a></td>

<td ID="menu_cell_reports" class="MenuTD" align="center"><a ID="menu_link_2" onclicq="menuGoUrl('reports_menu', parent.index_main)" href="#">Reports</a></td>

Both these links point to two different links and pages but show the same URL.


The JavaScript function which is being called:


[ October 24, 2005: Message edited by: Lasse Koskela ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Well, nothing jumps out at least to my eyes. I'd suggest the brunt force approach -- commenting out "extra" bits of the JavaScript to find out the minimal working set and then start uncommenting things until you find the part that HttpUnit's Rhino JavaScript engine can't deal with. (And then try to come up with another bit of JavaScript that it can deal with)

By the way, are you using IE specific stuff in there?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Oh, and Ulf is correct -- your display name does not conform to the policy, which only allows initials for the first name, not the family name. We'd appreciate it if you could take a minute to edit your profile. Thanks.
Venkata Kiran
Ranch Hand

Joined: Sep 06, 2005
Posts: 30
Are there any links to verify how HttpUnit works with Javascript Redirect
& frames.
Venkata Kiran
Ranch Hand

Joined: Sep 06, 2005
Posts: 30
is the problem bcos of the links being within <td> tags.
Is link click from <tr> supported in Httpunit now.
I saw this link & understood that the click was not working previously.
http://sourceforge.net/tracker/?group_id=6550&atid=356550
Request Id :1090785
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Kiran Kumar:
is the problem bcos of the links being within <td> tags.
Is link click from <tr> supported in Httpunit now.
I saw this link & understood that the click was not working previously.
http://sourceforge.net/tracker/?group_id=6550&atid=356550
Request Id :1090785

What that request is about is not your situation. The request talks about having something like this:

while you have something like this:
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Kiran Kumar:
Are there any links to verify how HttpUnit works with Javascript Redirect
& frames.

I'm not aware of any (but I also haven't looked).

What I'd suggest is try things out in a small, simple, isolated sandbox until you get an idea of what works and what doesn't.

For example, you could quickly sketch up a simple set of framed HTML pages with the simplest table you can think of, having the links and pieces of JavaScript you have in the actual application. You could dump these files on Apache and start hacking with a very fast cycle of 1) edit html/javascript, 2) verify visually in a browser, 3) run a simple HttpUnit test to see if HttpUnit can deal with what you have.



I'm not sure if you've already tried what I suggested earlier, about commenting out stuff that's sort of "extra". I'd probably start by commenting out these two pieces:

(simply because I can't see their sources and so I'm tempted to believe they might be doing something non-compatible)
Venkata Kiran
Ranch Hand

Joined: Sep 06, 2005
Posts: 30
The JS code is from a client's site which I am testing so I can't minimise or remove any part of the Javascript code.
But I found out this link which describes similar problem but used images
instead of normal text for hyperlinks :

https://sourceforge.net/forum/forum.php?thread_id=1317264&forum_id=20295

Trying out on that basis.
Thank u for the help.
[ October 26, 2005: Message edited by: Kiran Kumar ]
Venkata Kiran
Ranch Hand

Joined: Sep 06, 2005
Posts: 30
Hai ,
r there any examples for using WebWindow or WebClient in HttpUnit.
Thank u in advance.
Mat DeLong
Greenhorn

Joined: Dec 08, 2005
Posts: 2
Has a solution to this been found? I was using one version of httpUnit (unknown) and switched to another, and then my links which called javaScript functions stopped working.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Generally speaking, if HttpUnit/jWebUnit/HtmlUnit/whatever tool you're using suddenly stops supporting the kind of JavaScript you have in your application, I'd recommend taking it up on the respective tool's mailing list. If the JavaScript you've used is cross-browser compatible (or standard) then it's likely a bug. If not, then you should probably change your application anyway.
Venkata Kiran
Ranch Hand

Joined: Sep 06, 2005
Posts: 30
Sorry I was not able to get any break through and had to leave that in middle.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpUnit , Javascript Errors
 
Similar Threads
HttpUnit Question.
Problem in accessing script file
HttpUnit
Problem with Radio buttons
HTTPUnit - Accessing onClick event of button not in form