1

In a previous version of our application there was a SAP GUI SapTextField that allowed too long input. I'd now like to write a test that ensures the maximum input length of the textfield is limited.

Unfortunately I could not find a way to determine the width of the textfield in characters. The getWidth() method returns the width in pixels, not characters.

I know that using setText() causes a RuntimeException when the text is too long for the textfield, but using that as an indicator is dangerous since RuntimeException is used for many other problems as well.

Is there a way to determine the maximum width of a SAP GUI textfield in Silk4J?

Code that I have today:

try 
{
    SapTextField textfield = desktop.<SapTextField>find("...");
    textfield.setText("1234567");
    fail("The textbox should be limited to 6 characters");
}
catch(RuntimeException re)
{
    // TODO: find a more reliable way of detecting this
}
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
  • Can you please tag your question with the language you are using (which I assume is either C# or VB from the documentation link you provided). Also, give us the code for what you are trying to do. – Tim Biegeleisen Jun 25 '15 at 06:27
  • @TimBiegeleisen: the question is tagged Java, the term Silk4J is in the question title and text. The link refers to .NET since the Java documentation is not online. I have added code. – Thomas Weller Jun 25 '15 at 06:44

0 Answers0