Amanda_Smith Valued Contributor.
Valued Contributor.
297 views

Split String when there are no unique delimeters

Jump to solution

Hello,

Here is the scenario I am working with.

The report has a button 'Filters'. When 'Filters' button is clicked a little window pops-up which has 8 different Weblists. So, when you select any of the filters and then click apply, the values in the report change. 

On the top of the report after filters have been applied, the selected filter along with the selection value gets populated.

So, I need to verify if selection matches with the text after the filter/filters have been applied.

I figured out how to verify it when only one filter has been applied, but how to get the text if more than one filter is applied?

I have attached an image to illustrate: three filters selected. 
I have to verify that what I have selected matches with whats populated on the screen after they have been applied. 

0 Likes
1 Solution

Accepted Solutions
Highlighted
liorde Honored Contributor.
Honored Contributor.

Re: Split String when there are no unique delimeters

Jump to solution

Hi,
How does UFT "see" the line you marked in yellow? In terms of the object spy.

As one object? Is it a row in a webtable object?  When you select the filter, do you get 3 options in total?
You need to verify these *3* selections??
If yes, then I can suggest the follwing:

filt_1 = "SCHOOL:"
len_1 = len(filt_1)
filt_2 = "PROGRAM TYPE:"
len_2 = len(filt_2)
filt_3 = "QUARTER:"
len_3 = len(filt_3)

my_str = "SCHOOL:Saratoga high school  PROGRAM TYPE: PHYSICS QUARTER:SPRING"

first_selection     = trim(mid(my_str, instr(my_str,filt_1)+len_1, (instr(my_str, filt_2)-(instr(my_str, filt_1)+len_1))))
second_selection     = trim(mid(my_str, instr(my_str, filt_2)+len_2+1(instr(my_str, filt_3)-(instr(my_str, filt_2)+len_2+1))))
third_selection     = trim(mid(my_str, instr(my_str, filt_3)+len_3))

Then you will have your current filters in 3 different fields and you can compare it to what is expected.
Hope this helps.

 

0 Likes
2 Replies
Highlighted
liorde Honored Contributor.
Honored Contributor.

Re: Split String when there are no unique delimeters

Jump to solution

Hi,
How does UFT "see" the line you marked in yellow? In terms of the object spy.

As one object? Is it a row in a webtable object?  When you select the filter, do you get 3 options in total?
You need to verify these *3* selections??
If yes, then I can suggest the follwing:

filt_1 = "SCHOOL:"
len_1 = len(filt_1)
filt_2 = "PROGRAM TYPE:"
len_2 = len(filt_2)
filt_3 = "QUARTER:"
len_3 = len(filt_3)

my_str = "SCHOOL:Saratoga high school  PROGRAM TYPE: PHYSICS QUARTER:SPRING"

first_selection     = trim(mid(my_str, instr(my_str,filt_1)+len_1, (instr(my_str, filt_2)-(instr(my_str, filt_1)+len_1))))
second_selection     = trim(mid(my_str, instr(my_str, filt_2)+len_2+1(instr(my_str, filt_3)-(instr(my_str, filt_2)+len_2+1))))
third_selection     = trim(mid(my_str, instr(my_str, filt_3)+len_3))

Then you will have your current filters in 3 different fields and you can compare it to what is expected.
Hope this helps.

 

0 Likes
Knowledge Partner
Knowledge Partner

Re: Split String when there are no unique delimeters

Jump to solution

You could make it simpler and use InStr to verify your expected values are in the full string, not fool proof but simple.

Mark Smith.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.