Methods Return Incorrect Indexed Values in My Scripts

This functionality is supported only if you are using the Classic Agent.

There is an incompatibility in indexing between 4Test methods and native Java methods for classes such as ListBox, PopupList, and ScrollBar. 4Test methods are 1-based; Java native methods are 0-based. If you mix 4Test methods and native methods in a test script where you retrieve indexed values, you must compensate for the difference in indexing schemes to maintain the integrity of your test results.

We recommend that you do not mix methods in test scripts if at all possible. A good rule is that when both types of methods are available for all controls in your applications, use the 4Test methods only.

In situations where 4Test methods are not available for some of your classes and you must mix in native methods, use the following precautions when writing code to get indexed values:
  • Do not pass an index of 0 to a 4Test method.
  • Adjust indexes accordingly.

For ListBox Lb, the native Java AWT list method call Lb.getItem(n) retrieves the same value as the 4Test list method call Lb.GetItemText(n+1), but not the same value as Lb.GetItemText(n).