????5.DOM??WEB?????е?????????

????????DOM???QTP???????????

???????CurrentStyle???????

????HTML???

<style>
.class_visible{visibility:"visible"}
.class_hidden{visibility:"hidden"}
</style>
<div class=class_hidden id="ID_001">
<p>DHTML using DISPLAY</p>
</div>
QTP?д???
Set oElementDocument=Browser("micClass:=Browser").Page("micClass:=Page").WebElement("html id:=ID_001").Object
isVisible=oElementDocument.currentstyle.visibility
If isVisible="hidden" Then
msgbox "object is hidden"
Else
msgbox "object is visible"
End If

????????????QTP??Exist????????????????True???????????????????????У????????????????????Exist?????????????????????????????????????

??????Document?????μ?currentstyle??????????style sheets??

????????DOM????????

??????????????????DOM????????????????????????????1000????????HTML??棬?????????name???????text_??????????1??1000????????????£?

<html>
<head>
<script language="vbscript">
function msg
for i=1 to 1000
tt=tt+"<input type='text' name='text_"+cstr(i)+"'>"
next
Document.getElementByID("aaa").innerHTML=tt
end function
</script>
</head>
<body>
<input type="button" value="click it" onclick="msg">
<div id="aaa"></div>
</body>
</html>

?????????????????HTML??????HTML????????????1000?????????????QTP?????????DOM??????????????

????QTP????????????

Services.StartTransaction "inputvalue"
For i=1 to 1000
Browser("micClass:=Browser").Page("micClass:=Page").WebEdit("name:=text_"+cstr(i)).Set "value"+cstr(i)
Next
Services.EndTransaction "inputvalue"

?????????

????DOM?????????

Services.StartTransaction "inputvalue"
For i=1 to 1000
Browser("micClass:=Browser").Page("micClass:=Page").Object.getElementsByName("text_"+cstr(i))(0).value="value"+cstr(i)
Next
Services.EndTransaction "inputvalue"

?????????