Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to match weblist data with expected values
#1
Solved: 6 Years, 5 Months, 4 Weeks ago
Hello All,

I am new to UFT and I have this task where I need to perform a comparision between list of all the items available in a weblist with expected list. And I was told not use any excel or Local/global data sheets.

And this weblist I am talking about is common for different users but with no of items might vary. So I want parametrize this in way that I can use it as function and can use for diffrent users.

Below is the code I am using to capture all the weblist values. Since I am not supposed to use a excel or data sheets. I dont know hoe to compare with expected data.

Code:
all = Browser("B").Page("P").WebList("L").GetROProperty("all items")
arr = split(all, ";")


Please help
Reply
#2
Solved: 6 Years, 5 Months, 4 Weeks ago
It should be a simple thing to achieve.

What are the places where you are allowed to fetch expected data from? (flat file, database, anything else?)
Reply
#3
Solved: 6 Years, 5 Months, 4 Weeks ago
Hi Ankur,

We basically use parameter.item method to parameter anything, unfortunately our client wants it like that.

So the sample goes like this.

'Browser(b).page(p).weblist("listname").parameter.item("ParameterName") ' we pass name and value in the properties here'

Now this can be used to verify only one value. So is there any possible way to do this for list of parameter values. without using or placing the values in any external sources like Db, excel, datasheets etc?

Thanks in advance.
Reply
#4
Solved: 6 Years, 5 Months, 4 Weeks ago
I still don't get why they don't want you to use a proper file to store data but if they insist it is indeed doable.

Just store the entire list as a comma (or whatever delimiter you like) separated value in the parameter. Then split the variable and do the comparison.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#5
Solved: 6 Years, 5 Months, 4 Weeks ago
Can I get a sample Code on how to loop that and compare with the weblist. It would really help a lot
Reply
#6
Solved: 6 Years, 5 Months, 4 Weeks ago
Store both the lists as dictionary and then use this function to compare the two dictionaries. This is the most optimum method to compare two lists in VB Script. 
Code:
Function CompareArrays(array1, array2)

       'Do they have the same number of items?
       If array1.Count <> array2.Count Then
           CompareArrays = False
           Exit Function
       End If

       'Compare keys and values
       For Each Key in array1.Keys

               'Check Keys
               If NOT(array2.Exists(Key)) Then
                   CompareArrays = False
                   Exit Function
               End If

               'Check Value
               If array1.Item(Key) <> array2.Item(Key) Then
                   CompareArrays = False
                   Exit Function
               End If
       Next

       CompareArrays = True

 End Function

Code Source
A second method can be to use arrays and then using two loops compare the values of those arrays one by one (but it is not as optimized as the method above.)
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to select value from Weblist using QTP neenumaria 4 13,172 08-07-2018, 04:43 PM
Last Post: NovGirl
  finding expected value in webtable Anupama 8 2,859 05-23-2018, 06:20 PM
Last Post: Anupama
  WebElement (only Weblist) is not getting identified in QTP 11, Windows 7 priyaang 3 5,907 06-26-2015, 12:39 AM
Last Post: supputuri
  Application Issue on selecting value from weblist using UFT 12.1 on run sunilkgupta 0 2,278 01-01-2015, 08:22 PM
Last Post: sunilkgupta
  get visible cell data values from webtable Satwik 1 4,518 07-24-2014, 11:57 PM
Last Post: supputuri

Forum Jump:


Users browsing this thread: 1 Guest(s)