Page 1 of 1

Evaluating a List of Elements, code evaluates twice

Posted: Mon Mar 05, 2012 4:38 pm
by Pixi6s

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?

Re: Evaluating a List of Elements, code evaluates twice

Posted: Tue Mar 06, 2012 2:27 pm
by Support Team
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

Re: Evaluating a List of Elements, code evaluates twice

Posted: Wed Mar 07, 2012 3:50 pm
by Pixi6s
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.

Re: Evaluating a List of Elements, code evaluates twice

Posted: Thu Mar 08, 2012 10:32 am
by Support Team
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

Re: Evaluating a List of Elements, code evaluates twice

Posted: Thu Mar 08, 2012 8:31 pm
by Pixi6s
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);
}