• Post Reply Bookmark Topic Watch Topic
  • New Topic

Does FitNesse support JavaScript  RSS feed

 
John Meloro
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

I am just beginning to work with FitNesse and HTMLFixture so please
bear with me.

I have written a test that is supposed to verify that a reset button
in JavaScript actually clears the fields.

The JavaScript works in actual fact; however, my test case is failing.

Here is the test:

|!- HtmlFixture -!|
|frontBody|
|Type|input|1|username|
|Type|input|2|password|
|Type|input|3|login|
|Type|input|4|reset|
|Type|form|1|loginForm||
|Focus|username|
|Set Value|<valid username goes here>|
|Focus|password|
|Set Value|<valid password goes here>|
|Focus|reset|
|Javascript|
|Execute|onclick|
|Focus|loginForm|reset|
|Focus|username|
|Text|$blank$|
|Focus|password|
|Text|$blank$|

Here is the offending line of HTML:

<input type="image" src="login_13.gif" onclik="document.forms[0].reset(); blur(); return false;"/>

The test runs and fails. The web page never seems to get updated as far as FitNesse is concerned.

Any help would be appreciated...
Thanks in advance...
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know much about HtmlFixture, but it seems to make use of HtmlUnit, which supports JavaScript to some amount: http://htmlunit.sourceforge.net/javascript-howto.html

Some things I noticed, though:

- I guess "execute" executes some javascript method, but your input element doesn't call such a method - instead it executes some inline script.
- I'm not sure what the "Focus|reset" is supposed to do?
- "onclik" in your input element is probably missing a "c"?
 
John Meloro
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ilja,

Thank You for the reply.

I deliberately took the "c" out of "onclick" because the newsgroup filter would not let me post otherwise.


Execute is supposed to simulate executing a mouse click on an image with an action associated with it.

The action is supposed to clear the name and password fields.

I have slightly modified the test to set the fields, that I am trying to clear, to string variables.

The results were identical, which leads me to believe that the web page is not be being updated and so the test is evaluating an "old" copy.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see.

How does HtmlFixture know which image to click on?
 
John Meloro
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was "assuming" that the instruction "Focus|reset" was directing the tests attention to the correct image.

I mean I indicated that the fourth input was called "reset" and the test didn't throw any error...
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. As far as I can tell, the image tag you posted doesn't contain any indication that it is called "reset"? Could that be the problem?
 
John Meloro
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After a couple of days working with my Task Leader on the problem here is what we have discovered:

1) FitNesse is not the root cause of the problem.
2) There are at least two things going on:

a) FitNesse seems to disable ALL JavaScript by default. They mention this on their web site and say its because there are/were problems loading pages. It is easy to toggle JavaScript back on with the javascript command.

b) Having the FitNesse Script click on a link that is associated with an HTML Form will preserve the session you are in. If you click on any kink of other link it will throw away any session information and create a brand new session. The net effect was that the test was failing because it was always being presented with another login page. Look in the source code at HTMLFixture.java.

The remaining problems we are having are that FitNesse relies on HTMLUnit. The version of HTMLUnit that FitNesse relies on does not yet support some of the JavaScript functions we are using. So, it looks like there is going to be some "refactoring" to make it work with HTMLUnit.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!