Issue with accessing object properties

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

Issue with accessing object properties

Post by SurajJaldu » Thu Apr 12, 2012 1:09 am

Hi,

There are few hyper links in our web page and they look like a tabs. When I click any of them respective section displays and background of the link changes so that we know the tab has been selected. When I spy I can see that 'class' property as 'Selected' and I would like to use the same thing in my code to make sure navigation is successful.

Here goes my code.

Code: Select all

Ranorex.ATag mppElement = objRepo.HomePage.Self.FindSingle<Ranorex.ATag>(".//a[@InnerText='" + tabName +"']",2000);
					mppElement.Click();
If(mppElement.Class=="Selected")
{
//my Reporting
}
The above code finds the element, clicks on it but fails to retrieve the class property as I found it as Null when I debug.

Interestingly, If tab was already selected then this code can click the tab again and can see the class as 'Selected'.

Thanks,
Suraj

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

Re: Issue with accessing object properties

Post by SurajJaldu » Fri Apr 13, 2012 8:36 pm

Okay. I resolved it myself by getting the link again after clicking on it.

Code: Select all

Ranorex.ATag mppElement = objRepo.HomePage.Self.FindSingle<Ranorex.ATag>(".//a[@InnerText='" + tabName +"']",2000);
mppElement.Click();
Ranorex.ATag mppElement = objRepo.HomePage.Self.FindSingle<Ranorex.ATag>(".//a[@InnerText='" + tabName +"']",2000);
If(mppElement.Class=="Selected")
{
//my Reporting
}
Is there a better way to do this?

Thanks,
Suraj