How to get Element info for logging purpose

Ask general questions here.
chiranthurs
Posts: 20
Joined: Mon Oct 29, 2018 1:09 pm

How to get Element info for logging purpose

Post by chiranthurs » Wed Dec 16, 2020 8:29 am

Hi,

I want put a user info log to my generic function to click on an object and I have created my function as below

public static void ClickOnObject(Ranorex.Adapter element)
{
element.MoveTo();
element.Click()
Report.Info("User clicked on "+elementInfo.Name+""); //Giving error
}

but in report info i want to get the elementInfo which i am unable to get. Can you please suggest me how i can fetch the elementInfo of the element which i am passing as a parameter

Thanks,
Chiranth

User avatar
Mike K
Posts: 10
Joined: Wed Jun 28, 2017 5:58 pm

Re: How to get Element info for logging purpose

Post by Mike K » Thu Dec 17, 2020 2:49 pm

Hello,

What information are you trying to report from the object? If it is attribute info you will need to capture it first and they add it to the Report action. Here is an example of getting 'InnerText' value from an object.

string count = tdtagInfo.FindAdapter<TdTag>().Element.GetAttributeValueText("InnerText");

Hope this helps!