Wrong element found after control wrapper Refrech() call

4 posts, 0 answers
  1. Mykola
    Mykola avatar
    16 posts
    Member since:
    Aug 2011

    Posted 06 Apr 2013 Link to this post

    Hi All,
    Recently I faced with issue related to element refresh flow. I am able to reproduce it on very simple flow.
    The root cause of this issue is next: 
    Assume you are working with page which have 2 <div> panels with anchor inside panels. Anchor has equal ID's but different text.
    Only one panel can be visible at the moment.
    So, let's take anchor from second panel (suppose it visible now), then explicitly call refresh of this control. As result you will receive anchor from the first panel (which is invisible) and wrong control.
    Below I provide code snippet with demonstrate this issue and attached sample web page.

    string localPageIE = @"D:\DuplicateAnchorsID\DuplicateID.html";
    Manager.Current.LaunchNewBrowser(BrowserType.InternetExplorer);
    Manager.Current.ActiveBrowser.NavigateTo(localPageIE);
     
    Manager.Current.ActiveBrowser.RefreshDomTree();
    // get all anchors from second (visible) panel
    ReadOnlyCollection<HtmlAnchor> linkWrappers = Manager.Current.ActiveBrowser.Find.AllByXPath<HtmlAnchor>("//div[@class='linksGroup2']//a");
    // get second item from collection to demonstrate issue
    HtmlAnchor linkItem = linkWrappers[1];
    // log info before refresh call
    _logger.Info(string.Format("Requested Anchor: innerText - [{0}], tagIndex - [{1}]", linkItem.BaseElement.InnerText, linkItem.BaseElement.TagNameIndex));
    linkItem.Refresh();
    // log info before refresh call
    _logger.Info(string.Format("Requested Anchor: innerText - [{0}], tagIndex - [{1}]", linkItem.BaseElement.InnerText, linkItem.BaseElement.TagNameIndex));

    This code snippet produced next output:
    Requested Anchor: innerText - [Item5], tagIndex - [4]
    Requested Anchor: innerText - [Item2], tagIndex - [1]

    Reproduced on next configuration:
    OS: Win 7 64
    Browsers: IE9/10, Firefox/Chrome latest
    TTF: 2012.2.1317.0

    Any ideas how I can overcome this issue ?

    Thanks,
    Mykola
  2. Mykola
    Mykola avatar
    16 posts
    Member since:
    Aug 2011

    Posted 11 Apr 2013 Link to this post

    Any updates on this ?

    Thanks,
    Mykola
  3. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 11 Apr 2013 Link to this post

    Hello Mykola,

    My apologies for the delay getting back to you on this.

    I see what you mean. It is a Test Studio bug. I have filed a bug on this behavior here. My only suggestion is to replace the .Refresh with a .RefreshDomTree and re-find the element similar to this:


    string localPageIE = @"C:\Users\gibson\Documents\Support Issues\DuplicateID.html";
    Manager.Current.LaunchNewBrowser(BrowserType.InternetExplorer);
    Manager.Current.ActiveBrowser.NavigateTo(localPageIE);
     
    // get all anchors from second (visible) panel
    ReadOnlyCollection<HtmlAnchor> linkWrappers = Manager.Current.ActiveBrowser.Find.AllByTagName<HtmlAnchor>("a");
     
    // get second item from collection to demonstrate issue
    HtmlAnchor linkItem = linkWrappers[3];
     
    // log info before refresh call
    Log.WriteLine(string.Format("Requested Anchor: innerText - [{0}], tagIndex - [{1}]", linkItem.BaseElement.InnerText, linkItem.BaseElement.TagNameIndex));
     
    // log info after refresh call
    ActiveBrowser.RefreshDomTree();
    linkWrappers = Manager.Current.ActiveBrowser.Find.AllByTagName<HtmlAnchor>("a");
    linkItem = linkWrappers[3];
    //linkItem.Refresh();
    Log.WriteLine(string.Format("Requested Anchor: innerText - [{0}], tagIndex - [{1}]", linkItem.BaseElement.InnerText, linkItem.BaseElement.TagNameIndex));

    All the best,
    Cody
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  4. Mykola
    Mykola avatar
    16 posts
    Member since:
    Aug 2011

    Posted 15 Apr 2013 Link to this post

    Hello Cody,
    Thanks for provided suggestion and for tracked bug. Hope this issue will be fixed soon.

    Thanks,
    Mykola
Back to Top