Search code examples
c#javascriptwatin

Watin won't fire .change() event manually


I have a selectlist:

<select style="ime-mode: auto; background-color: rgb(255, 255, 255);" id="il_worksheettype" class="ms-crm-SelectBox" tabIndex="1100" name="il_worksheettype" attrPriv="7" attrName="il_worksheettype" req="2" defaultSelected="null">
<option title="" selected="selected" value=""></option>
<option title="Underwriting" value="102790001">Underwriting</option>
<option title="Claim" value="102790000">Claim</option></select>

and I have the code:

worksheetTypes.Option("Claim").Select();
ProtectionInfoTab.Frame(Find.ById("contentIFrame")).Eval("$('#il_worksheettype').change();");

The problem is that for some reason it just wont run the javascript or at least this is the impression I'm getting. When this code there are no exceptions thrown but it just does not seem to do anything when it should be making options on another selectlist appear.

any ideas?


Solution

  • Use RunScript instead of Eval. Eval seems to bind the change, but do not trigger the change.

    RunScript worked for me, where pk is the element reference.

    Element pk = BrowserInstance.TextField("password");    
    pk.DomContainer.RunScript("$('#" + pk.Id + "').change();");