How to output part of a value from an edit field in UFT GUI?
Question ID: 106565
0
0

I need to output part of a value from a text field, however when UFT returns the value, it returns all the text.

Example:
The field is displayed as "Travel ID 12345," I need the "12345" portion, but the output captures "ID 12345" or "Travel ID 12345."

Any suggestions?

Marked as spam
Posted by (Questions: 45, Answers: 1)
Asked on December 31, 2015 5:13 pm
637 views
Answers (2)
0
Private answer

As an alternative, you can also use the GetROProperty for the object, which most likely is a text property, but you can use the ObjectSpy to confirm this. You can then grab the text in one step:

myval = Browser(''Browser'').Page(''Page'').WebEdit(''captext'').GetROProperty(''text'')

Also, another technique to strip out values from the output (such as only wanting the numeric values in your case) is to use the RegExp object in VBScript. Here's an example of using this:

'Strip a string on all non-numeric characters using the RegExp object in VBscript

myval=''Test ID 12245'' 'original string value from your output

with new RegExp 'initiate the RegExp object
.global = true 'define scope
.ignorecase = false 'ignore the case of the string
.pattern = ''[^0-9]'' 'This is our pattern. The ^ indicates any character NOT equal to 0 through 9
MyREval = .replace(myval,'''') 'Replace the non-numeric characters with empty space
end with 'end the With statement (optionally used for readability)
msgbox MyREval 'display the converted string. you can use the value in your script and not display it, of course. It's only used as an example

Marked as spam
Posted by (Questions: 2, Answers: 477)
Answered on January 5, 2016 4:54 pm
0
Private answer

You can use string functions to parse the captured text
1. Create an Output Value in the script. This will write the value to the data table.
2. Read it from the data table into a variable.
3. Use the split function to split the string into an array. You may also need to use additional string functions, such as Left, Len, LTrim, RTrim, Trim, and Right. For more information on these functions, refer to the Microsoft VBScript Reference.
4. Write the desired value back to the data table.
Example:

' Create an output step
Browser(''Browser'').Page(''Page'').WebEdit(''captext'').Output CheckPoint(''captext'')
' Read the value from the data table
value = DataTable(''captext_value_out'')
msgbox value
' Split the string on spaces
b = split(value)
' Get the index for the last element in the array
cnt = Ubound(b)
' Write the value to the data table
DataTable(''captext_value_out'') = b(cnt)

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on December 31, 2015 5:15 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top