我目前正在嘗試設置WatiN來對新的CRM解決方案進行一些自動化測試。我們有一個稱爲高級查找的屏幕按鈕。
單擊此按鈕時,會彈出一個新彈出窗口。這個彈出窗口有一個下拉菜單,我想單擊它並從中選擇選項。WatiN - 從彈出窗口中選擇下拉菜單
對彈出窗口的代碼是:
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">
的華廷代碼,我有如下:
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>
可有人請指出哪裏出了問題。
謝謝。
編輯:
運行測試時,我目前收到此錯誤信息:
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()
編輯:更多的HTML代碼:
<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">
是的,彈出框架上有一個框架,我發現並使用下面的信息選擇該項目。 – user1361245 2012-05-29 15:46:59