Getting the maximum width of a textfield in Silk4J

80 views Asked by At

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
}
0

There are 0 answers