0

So I have been searching for an answer for this for a long time, and have come up with a temporary solution which i'll write below, but I was wondering if theres a more elegant one?

In the application im working on there is a weblist which can contain one of four values which are: 10,25,50,100. When a value is selected the web table below should show 10,25,50 or 100 results depending on the value selected of course.

Now when I call the standard Obj.Select "100" for example it changes the list box to 100 but nothing else happens. No event is triggered so the web table below remains the same. If I manually select 100 the web table updates to display 100 records.

I tried firing different events to the web list but none of them seemed to update the web table!

In the end I settled on the solution below:

Public Function CustomSelect(obj, strValue)

Dim intCounter, strProperty, boolItemInList, strEnabledOrDisabled, arrAllItems, strAllItems
Dim xCoord, yCoord

If strValue = "@@" Then
   Call AddComment("Passed in @@, skipping set function")
   Exit Function
End If

Reporter.Filter = rfEnableErrorsOnly
strProperty= obj.GetTOProperty("name")

If strProperty= "" Then 
    strProperty= obj.GetTOProperty("html id")
End If

Reporter.Filter = rfEnableAll

If obj.exist(5) Then
    XCoord = obj.GetROProperty("abs_x")
    YCoord = obj.GetROProperty("abs_y")
    strEnabledOrDisabled = obj.GetROProperty("disabled")
    If strEnabledOrDisabled = 0 Or strEnabledOrDisabled = "0" Then
        strAllItems = obj.GetROProperty("all items")
        arrAllItems = split(strAllItems,";")
        For intCounter = LBound(arrAllItems) to Ubound(arrAllItems)
            'Obj.SendKeys "{DOWN}"
            Obj.Select "#" & intCounter
            If arrAllItems(intCounter) = strValue Then
                Exit For
            End If
        Next
    Else
        Call ReportExpectedVsActual("Weblist is disabled: " & strProperty, False, True)
    End If
Else
    Call ReportExpectedVsActual("Weblist doesnt exist: " & strProperty, True, False)
End If

End Function

RegisterUserFunc "WebList", "CustomSelect", "CustomSelect"

I know it looks a bit messy but its all I can think of to get it working at the moment. Does anyone have any other ideas of what to try?

Cheers

Nick

Festivejelly
  • 670
  • 2
  • 12
  • 30

1 Answers1

1

There are at least two things to try:

Try to look into the source of the webpage to see how an action is triggered. It could be something like onchange='RefreshIt();' or you'll see an EventHandler attached to it, then you have to dig somewhat deeper.

If you have indentified the event that will update your page, try firing that event after updating the list with WebListObject.FireEvent {yourEvent}. yourEvent could be a string containing onchange, onclick, ondblclick, onblur, onfocus, onmousedown, onmouseup, onmouseover, onmouseout, onsubmit, onreset or onpropertychange.

Another way that is even simpler (but giving you less control) is worth a try. This is done through the settings: Go to Tools > Options and in the tree view, select Web > Advanced. Try what happens when changing the checkbox for Run only click and the radiobuttons for Replay type.

AutomatedChaos
  • 7,267
  • 2
  • 27
  • 47
  • It turns out our developers used some obscure way of updating the page. Ive now got them to change how the list box updates and the script works :) Thanks for the help :) – Festivejelly Feb 18 '13 at 11:43