views:

252

answers:

3

I have a select list where a change event has been bound to the element using jQuery. Something like this:

$("#someId").change(function() {..});

When someone chooses a new option in the select list, another part of the UI will change accordingly. Now this works fine when I use the mouse and click things, however, when using Watij to write my tests I need the jQuery change event to fire which it isn't doing.

The Watij test will correctly choose the select option required but the actual event does not get triggered. I have tried calling fireevent("change"); and fireevent("onchange"); to no avail. I have also tried ie.sendKeys("{ENTER}"); and ie.sendKeys("{TAB}"); which also does not seem to do the trick.

Any ideas?

+1  A: 

The only solution I've found so far is to roll back the version of jQuery in use. I'm currently using version 1.4.1 (the offending version in regards to the testability of the change event on select boxes) and after going back to version 1.2.6 the problem goes away.

digiarnie
+1  A: 

Use $('#someId').trigger('change'); to fire the event manually.

See the documentation for trigger().

henchman
A: 

When the combo/list value is changed with script the onchange is not supposed to fire. I don't know how Watij is doing that, but this is one case.

Second thing is that Watij is working with IE (as long as wikipedia is rght) and IE is putting a system control in place of Your list or combo and it might break something too. Try upgrading to IE8 which has a tiny bit better realisation of form components (eg. select finally supports "disabled" attribute in options after 10 years)

You might also be interested in a normal application GUI testing apps and use them on a browser with the webapp. Record a macro and check screenshots.

naugtur