I am using watin to test a web page. The vast majority of which works fine. But I have a function that is run using JQuery. When the option of a SelectList is changed. When I run the browser and I have a break point in the js code the following jquery selector is fired.
$("#OwningRegion").change(function () {
But I cannot cause this to happen with watin. I have tried the FireEvent("change"). I have tried FireEvent("onClick"). I have tried .Option[1].Click(). etc.
Try this one:
browser.Eval(string.Format("$('#{0},.{0}').change();", id)); //Both for classes and id's
jQuery-style selector support is now built-in to WaTiN 2.0:
A new method Find.BySelector is added. It accepts any valid
jQuery/Sizzle CSS selector string. The following scenarios are
supported:
var element = browser.Element(Find.BySelector(…));
var div = browser.Div(Find.BySelector(…));
var elements = browser.Elements.Filter(Find.BySelector(…));
var buttons = browser.Buttons.Filter(Find.BySelector(…));