This is a migrated thread and some comments may be shown as answers.

RadAjaxPanel - Can't find child links

2 Answers 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 12 Jul 2010, 05:31 PM
Hi,

I have a page that contains a RadAjaxPanel, i am trying to write test code to validate the contents of a list that is async loaded in the ajaxPanel.

Here is the basic structure of my page and UserControls:

default.aspx
<telerik:RadAjaxPanel ID="ajaxPanel_Activities"
runat="server" EnableAJAX="true"
LoadingPanelID="loadingPanel_Activities"
RequestQueueSize="1">
     <div>
         <ahp:ActivitiesTabPanel runat="server" ID="activitiesTabPanel" />
     </div>
</telerik:RadAjaxPanel>

 
ahp.ahp:ActivitiesTabPanel UserControl
<div class="wideColumn">
    <telerik:RadMultiPage ID="radMultiPage_ActivitiesLists" runat="server" SelectedIndex="0">
       <telerik:RadPageView ID="radPageView_ActivitiesListLive" runat="server">
             <ahp:ActivitiesList ID="activitiesList_Live" runat="server"                   NumberOfResults="0" ReferenceActivityGroupName="Activities Page - Lives" OnMouseOver="showActivityContent('{0}', '{1}', '{2}');"         OnMouseOut="startTimer();"/>
        </telerik:RadPageView>
    </telerik:RadMultiPage>
<div>


ahp.ahp:ActivitiesList  UserControl

<asp:Repeater ID="rptActivities" runat="server" OnItemDataBound="rptActivities_ItemDataBound" >
    <ItemTemplate>
       <asp:LinkButton ID="linkTopic" runat="server" Text='<%# Eval("Topic") %>' CommandName="Click" CommandArgument='<%# Eval("ActivityId") %>' OnCommand="activityLink_Command" />
    </ItemTemplate>
</asp:Repeater>


So I am trying to find all the HtmlAnchors that are rendered by the ahp:ActivitiesList  UserControl.
But the linksInPanel Never contains the elements that are actually displayed.


Here is my test code

HtmlDiv ajaxPanel = _manager.ActiveBrowser.Find.ById<HtmlDiv>("ctl00_ctl00_cphContent_plcContent_ajaxPanel_Activities");
            Thread.Sleep(3000); //Give time for ajaxPanel to load.
 
            ReadOnlyCollection<HtmlAnchor> linksInPanel =ajaxPanel.Find.AllByTagName<HtmlAnchor>("a");
            HtmlAnchor match = null;
            foreach (HtmlAnchor ank in linksInPanel )
            {
                if (activities.ActivityTarget[0].Topic.ToLower().Trim() == ank.BaseElement.InnerText.ToLower().Trim())
                {
                    match = ank;
                    break;
                }
            }
            Assert.IsTrue(match != null);


Is this a limitation caused by the dynamically loaded markup in the ajaxPanel?
Or am i just not looking for my links in the right way?

Thanks for any help,
Daniel
delofer@aptilon.com

2 Answers, 1 is accepted

Sort by
0
Missing User
answered on 12 Jul 2010, 11:58 PM
Hi Daniel,

After the Thread.Sleep(3000),please try adding ActiveBrowser.RefreshDomTree(). If the panel happens to be in a frame, you can use the Find as in ActiveBrowser.Frames[index].Find, or if a popup window, Manager.Browsers[index].Find.

If the links are not ancestors of the panel, then ajaxPanel.Find.AllByTagName may still not return anything. So please verify in the generated html if this is the case, and if not, please try using the Find on over another parent page element or using ActiveBrowser.Find.

Sincerely,
Nelson Sin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Daniel
Top achievements
Rank 1
answered on 13 Jul 2010, 05:41 PM
Hi Nelson,

Thanks for the info, ActiveBrowser.RefreshDomTree() did the trick, that's all i was missing.

Dan
Tags
General Discussions
Asked by
Daniel
Top achievements
Rank 1
Answers by
Missing User
Daniel
Top achievements
Rank 1
Share this question
or