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

Wrong element found after control wrapper Refrech() call

3 Answers 34 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mykola
Top achievements
Rank 1
Mykola asked on 06 Apr 2013, 12:01 PM
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

3 Answers, 1 is accepted

Sort by
0
Mykola
Top achievements
Rank 1
answered on 11 Apr 2013, 05:45 PM
Any updates on this ?

Thanks,
Mykola
0
Cody
Telerik team
answered on 11 Apr 2013, 10:33 PM
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
0
Mykola
Top achievements
Rank 1
answered on 15 Apr 2013, 01:51 PM
Hello Cody,
Thanks for provided suggestion and for tracked bug. Hope this issue will be fixed soon.

Thanks,
Mykola
Tags
General Discussions
Asked by
Mykola
Top achievements
Rank 1
Answers by
Mykola
Top achievements
Rank 1
Cody
Telerik team
Share this question
or