cancel
Showing results for 
Search instead for 
Did you mean: 

How do we fetch the text from a input box in SAP GUI desktop client using c# (Automation)

0 Kudos

I'm trying to automate SAP GUI Desktop client in C# and using these article as an reference for the same

I'm able to launch the GUI and perform the required operations but unable to fetch text from a input box and then some text from the execution logs. I have tried this code to get the text but this doesn't seems to be working.

GetProperty(this.ID, "text", new object[1] { requiredLocator })

The error that I get is

CLR/System.Reflection.TargetInvocationException

which will occur if the locator is not loaded properly, which is not the case here.

Is there any way we can fetch the text? Also, is this the recommended way to do this?

Former Member
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with: https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.

For example, you can:

- outline what steps you took to find answers (and why they weren't helpful)

- share screenshots of what you've seen/done

- make sure you've applied the appropriate tags

- use a more descriptive subject line

The more details you provide, the more likely it is that members will be able to respond. Feel free to also take our Q&A tutorial at: https://developers.sap.com/tutorials/community-qa.html

Should you wish, you can revise your question by selecting Actions, then Edit.

By adding a picture to your profile you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html

Questions on how to draw responses from members? Check out this discussion on how to improve questions. https://groups.community.sap.com/t5/welcome-corner-discussions/advice-from-sap-champions-questions-a...

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

I got the answer by trial and error.I was using the wrong method. Writing it here as an answer as it could be helpful to someone.

Instead of this method

  GetProperty(this.ID, "text", new object[1] { requiredLocator })


We should use this method

  InvokeMethod(this.ID, "Text", new object[0])

where the *requiredLocator* and *ID*

can be set as

  this.ID = InvokeMethod(this.session, "findById", new object[1] { requiredLocator})