Updating OR item property

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
SurajJaldu
Posts: 29
Joined: Sat Feb 25, 2012 12:10 am

Updating OR item property

Post by SurajJaldu » Wed Jun 20, 2012 1:04 am

Hi,

There is a breadcrumb in our web application which gets updated with new text when we click few links on the page. I need to verify that the breadcrumb gets updated with new text after I click on a link.

Now, my old code is

Code: Select all

myOR.Home.myLink.click();
Delay.Seconds(3);
if(myOR.Home.BreadCrumb.InnerText=="exptext"){ return success;}
I had to use Delay because BreadCrumb already exists on the page so sometimes when application is slow, Ranorex gets the old text and test fails.

So, I've improved the code.. by updating OR item's properties at run-time.

Code: Select all

myOR.Home.myLink.click();
string text = "exptext";
string BreadCrumbPath = myOR.Home.BreadCrumbInfo.Path.ToString();
BreadCrumbPath  = BreadCrumbPath.Substring(1, BreadCrumbPath.Length-2);
BreadCrumbPath += " and @InnerText='" + text + "']";
myOR.Home.BreadCrumbInfo.Path = BreadCrumbPath;
obj = Host.Local.FindSingle(myOR.Home.BreadCrumbInfo.AbsolutePath, 10000);
if(obj.Exists()){ return success;}
Is there a better way to update OR item's properties?

[NOTE]: Code in this post is just pseudo code.
Thanks,
Suraj

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

Re: Updating OR item property

Post by Support Team » Wed Jun 20, 2012 4:03 pm

Hi,

I would recommend to track the parent of the bread crumb path and simple search from this position.
Doing so, it's not necessary to use the string manipulations you've posted.
...
Element parent = "/path/to/the/parent/element";
...
parent.FindSingle("./*[@text='<expectedText1>']",10000);
...
myOR.Home.myLink.click();
parent.FindSingle("./*[@text='<expectedTex2t>']",10000);
...
Whereas <expectedText> is the actual text you want to validate.

Regards,
Tobias
Ranorex Team
.
Image

SurajJaldu
Posts: 29
Joined: Sat Feb 25, 2012 12:10 am

Re: Updating OR item property

Post by SurajJaldu » Wed Jun 20, 2012 6:12 pm

Yeah. That would work. Thanks.