Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do i ensure that displayed values are in ascending order in a web page
#1
Solved: 11 Years, 3 Months, 2 Weeks ago
Scenario:
I have a link "FieldName' and we could see 200 fields under this link when i click on this link all the fields under this link would be displayed in ascendin order , when i click on once again all the fields would be displayed in descedning order
Query: How do i ensure that the displayed values are in ascending order

Note: I could able to retrieve all the fields in to variables here main issue is how to validate that all fields are in ascending order


Could you please refresh me about this issue and let me know if u have any better solution..
Reply
#2
Solved: 11 Years, 3 Months, 2 Weeks ago
as said
(07-31-2009, 10:23 AM)venkatbatchu Wrote: Note: I could able to retrieve all the fields in to variables here main issue is how to validate that all fields are in ascending order

get all this into an array variable
and using following function you can determine whether they are in ascending order.
Code:
Function IsAscending(sArray)
'Assign default value of IsAscending
IsAscending = true
For i= 0 to UBound(sArray) - 1
If sArray(i) > sArray(i+1) Then
'Return value of IsAscending
IsAscending = false
exit for
End If
Next
End Function

This function will return true if array is in ascending order.
hope this will help you

Reply
#3
Solved: 11 Years, 3 Months, 2 Weeks ago
Hi,
This is true it will work and which is developed based on bubble sort but the problem will arise only when fields are more for ex: if i have 200 fields under this link 200x(200-1)=39800 times it will execute and perfoemace of the script would be obviously less and it will take more time to execute the script. Hopefully this kind of function is not acceptable.

I have done with this in a different manner
1.First i took all the variables in to one excel sheet(excel1.xls)
2. Arranged these values in excel1.xls in ascending order and saved with the ascending order values
3. Click on the link on web page and observe that fields will be displayed in ascending order
4. Now i again export all the variables in to excel sheet (excel2.xls)
5. Now i have compare shell by cell with excel1 and excel2.xls
6. Found the mismatched results

to execute the script with the above process it took just less than 3 minutes if i use the bubble sort it has not been completed in 1.5 hour

This is the way i have proceed,

Please let me know if there is any better solution otherthan this...

Thanks,
Venkat.Batchu
Reply
#4
Solved: 11 Years, 3 Months, 2 Weeks ago
I wonder how it takes more than 1.5 hours for checking 200, I have just checked with 300 records and returned back to me within 9 secs.
If possible Can you please provide with your code where it takes so long time? I would like to try this for any better solution for your purpose, but I implemented this for many times and I dont have any performance issue so far.

Reply
#5
Solved: 11 Years, 3 Months, 2 Weeks ago
Hi,
I just tried with ur example still it is taking more time and got the error message of script out of range.

Code:
Dim n(271)
m=Browser("……").Page("……..").Frame("……..").WebTable("……….").RowCount
msgbox m
For i=3 to m-1 step 1
n(i)=Browser("………").Page("……..").Frame("…….").WebTable("…….").GetCellData(i,2)
Call IsAscending (n)
Next
Function IsAscending(n)
'Assign default value of IsAscending
IsAscending = true
For i= 0 to m - 1
If n(i) > n(i+1) Then
'Return value of IsAscending
IsAscending = false
exit for
End If
Next
End Function

Note: The funtion u wrote will validate between the previous value (i) and next value (i+1) which will not validate between i and i+2
EX:
Please find the below list:
amar 1
batchu 2
akbar 3
anand 4
venkat 5
The mentioned function will validate only in between 1 and 2, 2 and 3 , 3 and 4, 4 and 5 this is the way it would proceed it will not compare in between 1 and 3 , 1 and 4 . So with this the function may not fullfill the required scenario.
Can you please let me know if there is better solution aprt from this .
Please let me know if i am going in wrong direction
Reply
#6
Solved: 11 Years, 3 Months, 2 Weeks ago
Yes you are right venkat, the function will validate only in between 1 and 2, 2 and 3 and so on. but the function is designed in the same way only that if the first comparison fails then it determines that the array is not in order. say n(1) = 5, n(2) = 6, n(3) = 4 then as statement in the function
Code:
If n(i) > n(i+1) Then
'Return value of IsAscending
IsAscending = false
exit for
End If
if n(1) > n(2) then ie 5 > 6 (will return false)
and conciders the two is in order again
if n(2) >n(3) ie 6 > 4 (will return true)
which is not in order and so the function will return false
and it can be determined that the array is not in ascending order.
As per my knowledge, I dont think the logic is wrong anywhere, let me know if I am wrong somewhere.

Regarding time, I think the way you have written statement is causing the issue. the function call 'IsAscending (n)' should be out of the for loop. Idea is first get all the cell values into array then compare.

Reply
#7
Solved: 11 Years, 3 Months, 2 Weeks ago
To validate all the values u could use bubble sort:
For ex:
Code:
Sub BubbleSort(arr As Variant, Optional numEls As Variant, _
    Optional descending As Boolean)

    Dim value As Variant
    Dim index As Long
    Dim firstItem As Long
    Dim indexLimit As Long, lastSwap As Long

    ' account for optional arguments
    If IsMissing(numEls) Then numEls = UBound(arr)
    firstItem = LBound(arr)
    lastSwap = numEls

    Do
        indexLimit = lastSwap - 1
        lastSwap = 0
        For index = firstItem To indexLimit
            value = arr(index)
            If (value > arr(index + 1)) Xor descending Then
                ' if the items are not in order, swap them
                arr(index) = arr(index + 1)
                arr(index + 1) = value
                lastSwap = index
            End If
        Next
    Loop While lastSwap
End Sub
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Web page not loading for EBS application when open UFT satyagadam 1 1,755 09-18-2019, 02:30 AM
Last Post: satyagadam
  Facing a problem while identifying Angular JS objects in a web page vangasantosh 0 1,216 12-20-2017, 01:26 PM
Last Post: vangasantosh
  capturing message on web page when caps lock is on helan 0 2,365 04-29-2015, 05:25 AM
Last Post: helan
  IE 11 has stopped working is displayed while running UFT 12 iahmad 0 1,926 04-06-2015, 06:44 PM
Last Post: iahmad
  qtp 11, Unable to prove the disappearance ofdynamic objects displayed on same screen. priyaang 1 2,442 03-24-2014, 12:53 AM
Last Post: supputuri

Forum Jump:


Users browsing this thread: 3 Guest(s)