0

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.

Peter Marshall
  • 1,231
  • 1
  • 13
  • 22
  • I found my own answer. In StackOverflow .... http://stackoverflow.com/questions/3712825/unable-to-fire-jquery-change-event-on-selectlist-from-watin – Peter Marshall Oct 24 '11 at 14:34

2 Answers2

1

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(…));
Richard Dingwall
  • 2,692
  • 1
  • 31
  • 32
1

Try this one:

browser.Eval(string.Format("$('#{0},.{0}').change();", id)); //Both for classes and id's
alonp
  • 1,307
  • 2
  • 10
  • 22