Page 1 of 1

Issue with accessing object properties

Posted: Thu Apr 12, 2012 1:09 am
by SurajJaldu
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

Re: Issue with accessing object properties

Posted: Fri Apr 13, 2012 8:36 pm
by SurajJaldu
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