Evaluating a List of Elements, code evaluates twice

Ranorex Spy, Recorder, and Studio.
Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Evaluating a List of Elements, code evaluates twice

Post by Pixi6s » Mon Mar 05, 2012 4:38 pm

Code: Select all

		
string sInner;	
string sList_EmailSubject = ".//div/div[@id='sr']/div[@id='divSubject']";
Report.Log(ReportLevel.Info, "Auto", "Evalate Email List");
IList<Ranorex.DivTag> emails = Host.Local.Find<Ranorex.DivTag>(sList_EmailSubject);
foreach (Ranorex.DivTag email in emails) 
{
     sInner = email.InnerText.ToString();
     Report.Log(ReportLevel.Info, "Auto", sInner);
}
When I run this code block, no matter what element I am using, it always evaluates everything twice. EG, If I run exactly what I have above on owa outlook, it will report out all my email subjects twice.

Is there anything I can change to make it only evaluate them all once?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Evaluating a List of Elements, code evaluates twice

Post by Support Team » Tue Mar 06, 2012 2:27 pm

Hi,

Maybe there are more elements with the same "InnerText" and "id", do you have checked with Spy which elements are found if you input the specific RxPath?
Can you send us a Ranorex Snapshot file of the application under test?
Following link will show you how to generate a snapshot file:
http://www.ranorex.com/support/user-gui ... -files.htm

Regards,
Markus
Ranorex Support Team
.
Image

Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Re: Evaluating a List of Elements, code evaluates twice

Post by Pixi6s » Wed Mar 07, 2012 3:50 pm

Hmm... i find that unlikely. This same code block when used on different places on the website I test and it found everything I expected then them all again. But before it didn't matter, this is the first time where I wasn't planning on breaking after a specific element is found. Now I am using it with owa outlook evaluating the messages available, and it is finding all the messages in the list twice. Completely unrelated application and different elements, I've used it with DIV, SPAN, IMG, HREF all with the same issue.
Attachments
RB_20120307_092800.rxlog
log
(16.41 KiB) Downloaded 174 times
outlook.rxsnp
Snapshot of list of emails in owa outlook
(726.34 KiB) Downloaded 153 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Evaluating a List of Elements, code evaluates twice

Post by Support Team » Thu Mar 08, 2012 10:32 am

Hi,

Thanks for the files!
The Snapshot looks okay for me, but it is not the best idea to search from the local host for the specific elements without including the dom object to the RxPath.
Maybe there are more instances of Outlook running?
Please try to use the following RxPath, because the dom object is explicit named:
/dom[@domain='west.exch023.serverdata.net']/.//div/div[@id='sr']/div[@id='divSubject']
Are the objects still reported twice?
If yes, input the specific RxPath into the Spy tool, are you getting the same output as in the report file, are the elements shown twice?

Regards,
Markus
Ranorex Support Team
.
Image

Pixi6s
Posts: 92
Joined: Tue Jun 28, 2011 8:57 pm

Re: Evaluating a List of Elements, code evaluates twice

Post by Pixi6s » Thu Mar 08, 2012 8:31 pm

Oh thank you!

Actually based on mentioning host local is bad, I declare a webdocument and not only does it no longer duplicate it is also SO much faster. I was given this code snippit and never really evaluated it. Also I have been learning alot over the last few months.

Thanks for the push.

Code: Select all

string sInner;   
string sList_EmailSubject = ".//div/div[@id='sr']/div[@id='divSubject']";
WebDocument wd = "/dom[@domain='west.exch023.serverdata.net']";

Report.Log(ReportLevel.Info, "Auto", "Evalate Email List");
IList<Ranorex.DivTag> emails = wd.Find<Ranorex.DivTag>(sList_EmailSubject);
foreach (Ranorex.DivTag email in emails) 
{
     sInner = email.InnerText.ToString();
     Report.Log(ReportLevel.Info, "Auto", sInner);
}