开发者

QTP - JavaTable - GetCellData - Displaying values with leading zeros

I have JavaTable with values like 1,0200,300,0003000 etc.

When I use GetCellData(x,y) function to retrieve values QTP trims the leading zero's in values. It returns the result like 200,3000 instead of 0200, 0003000

I need the exact values from the table to perform some string comparison. There is no way for me in advance to know how many zeros, if any, is leading.

Please let me know if you know 开发者_开发百科how to overcome this issue.

Or if you know of another way of getting the Cell Data from a JavaTable which does not trim the leading zeros.

Thanks in advance.

Best Regards

Jonas


The clipboard might help - you could try using keystrokes to select all and copy the text of the table to the system clipboard, and then use the clipboard api to retrieve the contents of the clipboard for parsing.

Set clipboard = createobject("mercury.clipboard")
text = clipboard.GetText()

Alternatively, assuming it does not invalidate your test, you could trim the leading zeros from your expected values prior to the string comparison. Or if the field values have a fixed length, you could determine at runtime how many zeros are missing and pad the actual values appropriately prior to the string comparison.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜