我在 html 中有以下代码用于 WebTable(Web 网格)。
<table width="90%">
<div class="greybox" style="margin-top:2%;">
<table class="datagrid" width ="100%">....<table>
</div>
</table>
我尝试在我的描述性编程中提供完全相同的(所有)属性,但 QTP 没有识别 Web 元素(DIV)。有没有一种独特的方法来识别这个?
注:网页为单页应用开发
编辑:
所以我想我已经用下面的代码解决了这个问题。在没有“唯一文本”if 子句的情况下标识了两个对象。第一个对象是 DIV 对象的父对象,因此必须使用第一个对象的“唯一文本”,该对象不属于任何其他对象。我目前正在尝试使用不同的数据来查看它是否工作正常
Browsername = Browser("micClass:=Browser").GetROProperty("name")
Pagename = Browser("micClass:=Browser").Page("micClass:=Page").GetROProperty("name")
Set desc = Description.Create()
desc("micclass").Value = "Webelement"
Set ChildObject=Browser("name:="&BrowserName).Page("name:="&PageName).ChildObjects(desc)
Set Child_Table_Value = nothing
For i=0 to ChildObject.Count-1
innerhtmlvalue = ChildObject(i).GetRoproperty("innerhtml")
htmltag = ChildObject(i).GetRoproperty("micclass")
if(Instr(innerhtmlvalue, "MARGIN-TOP: 2%")<>0) then
if(Instr(innerhtmlvalue, "UniqueText")=0) then
if(Instr(htmltag, "WebElement")<>0) then
Set Child_Table_Value = ChildObject(i)
End If
End If
End IF
Next
Set Table_Value = Child_Table_Value.WebTable("html tag:=Table")