0

所以我一直在寻找这个问题的答案很长一段时间,并想出了一个临时解决方案,我将在下面写下,但我想知道是否有更优雅的解决方案?

在我正在处理的应用程序中,有一个网络列表可以包含以下四个值之一: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.

现在,当我调用标准 Obj.Select “100” 时,它会将列表框更改为 100,但没有其他任何反应。没有触发任何事件,因此下面的 web 表格保持不变。如果我手动选择 100,则 Web 表会更新以显示 100 条记录。

我尝试向网络列表触发不同的事件,但它们似乎都没有更新网络表!

最后,我确定了以下解决方案:

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"

我知道它看起来有点乱,但我现在能想到的就是让它工作。有没有人对尝试什么有任何其他想法?

干杯

缺口

4

1 回答 1

1

至少有两件事可以尝试:

尝试查看网页的来源以了解操作是如何触发的。它可能是类似的东西,onchange='RefreshIt();'或者你会看到一个EventHandler附加的东西,然后你必须更深入地挖掘。

如果您已识别将更新您的页面的事件,请尝试在使用 更新列表后触发该事件WebListObject.FireEvent {yourEvent}yourEvent可以是包含 onchange、onclick、ondblclick、onblur、onfocus、onmousedown、onmouseup、onmouseover、onmouseout、onsubmit、onreset 或 onpropertychange 的字符串。

另一种更简单(但控制更少)的方法值得一试。这是通过设置完成的:转到Tools > Options并在树视图中,选择Web > AdvancedRun only click尝试更改复选框和单选按钮时会发生什么Replay type

于 2013-02-05T16:39:18.040 回答