I am currently trying to set up WatiN to do some automated testing of a new CRM solution. We have a screen button called Advanced Find.
When this button is clicked, a new pop up opens. This popup has a drop down menu and I would like to click it and select on option from it.
The code for the pop up window is:
td class="ms-crm-AdvFind-Label"><br>
td class="ms-crm-AdvFind-EntityList"> <br>
select name="slctPrimaryEntity" class="ms-crm-SelectBox " id="slctPrimaryEntity" Sort="ascending" defaultSelected="activitypointer"><br>
option title="Organisations" value="account">
The WatiN code I have is as follows:
ie.Image(Find.ByClass("ms-crm-ImageStrip-advancedfind32")).Click();
IE poppedUpBrowser = IE.AttachTo<IE>(Find.ByTitle("Advanced Find - Microsoft Dynamics CRM"));
SelectList ddl = poppedUpBrowser.SelectList(Find.ByClass("ms-crm-AdvFind-Label")&(Find.ById("slctPrimaryEntity")));<br>
ddl.Option("Organisations").Select();<br>
Assert.That(ddl.SelectedItem.Equals("Organisations"));<br>
Can someone please point out where I have gone wrong.
Thanks.
Edit:
I am currently getting this error message when running the test:
Failure: WatiN.Core.Exceptions.ElementNotFoundException : Could not find OPTION element tag matching criteria: Attribute 'innertext' equals 'Organisations' ignoring case at http://website
Stack Trace:
at WatiN.Core.Element.get_NativeElement()
at WatiN.Core.Element.GetAttributeValueImpl(String attributeName)
at WatiN.Core.Component.GetAttributeValue(String attributeName)
at WatiN.Core.Option.setSelected(Boolean value, Boolean WaitForComplete)
at WatiN.Core.Option.Select()
Edit: More HTML code:
<tbody>
<tr height="100%">
<td class="AdvFind_td_FindBody">
<span id="advancedFind">
<table class="ms-crm-AdvFindControl" id="advFind" cellSpacing="0" cellPadding="0" EntityName="activitypointer" UIProvider="" DataProvider="" EntityTypeCode="4200" DisableValueControlInSimpleMode="0" DistinctFetch="1" SaveChangesAlert="1" IncludeUserQuery="1" IncludeSystemQuery="1" ValidQueryType="0" FilterControlVisible="1" TitleVisible="0" EntityListVisible="1" RelatedEntitiesVisible="1" QueryListVisible="1" CanCreateUserQuery="1" CanWriteUserQuery="1" IncludeAPIQuery="0" FetchMode="2" Buttons="1023" Modes="3" Mode="1" aliasesInInitialFetch="">
<tbody>
<tr class="ms-crm-AdvFind-TitleArea">
<td>
<table class="ms-crm-AdvFind-Title-table" style="table-layout: fixed;">
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td class="ms-crm-AdvFind-EntityList">
<select name="slctPrimaryEntity" class="ms-crm-SelectBox " id="slctPrimaryEntity" Sort="ascending" defaultSelected="activitypointer">
<option title="Activities" value="activitypointer">
<option title="Addresses" value="customeraddress">
Is the popup inside a frame. If so, you will need to traverse from the Frame.
Let me know how it goes.