首页 > 解决方案 > .GetRoProperty 的 UFT/QTP 一般运行时错误

问题描述

您好,我收到一般的运行时错误。这与预加载的下拉菜单一起使用,在此之前我还有另一个功能可以正常工作。但是当它尝试运行它时,我得到了错误。

我尝试过使用不同的属性,如内文、html id 等。但这会得到相同的错误。

Sub WebList(DropDown)

    Set myPage=Browser("title:=.*").Page("title:=.*")    
    Set myWebList=Description.Create()
    myWebList("micClass").value="WebList"
    Set AllWebList=myPage.ChildObjects(myWebList)
    totalWebList=AllWebList.count()

    For i = 0 To totalWebList
       If AllWebList(i).GetRoProperty("name") = DropDown  Then
           AllWebList(i).select ("GO") 
           wait(3)
           Exit for    
       End If       
   Next

   Set myPage = nothing
   Set myWebList2 = Nothing
   Set AllWebList2 = nothing        
End Sub

我希望选择下拉列表。感谢您的任何帮助/建议。此外,如果我可以改进任何线路以使其成为动态且经验丰富的编码器,请建议他们。

标签: runtime-errorqtphp-uft

解决方案


您的For循环中有一个错误,如果没有具有指定名称的列表,您将访问比实际存在的列表多一个。这是因为To在 vbscript 中是包容性的,并且索引从0. 如果找到该列表,则该代码对我有用。

For循环应该是:

For i = 0 to totatlWebList - 1

推荐阅读