|
第一个问题 如何让combox自动选取它的子项?
这里我自己写了一个html页面,就是简单模拟了一下功能!
<html>
<head>
<title>
Combobox
</title>
</head>
<body>
这是一个Combo的测试
<p><select size="1" name="D1">
<option>1</option>
<option>2</option>
<option>3</option>
</select></p>
</body>
</html>
Sub Main
Dim Result As Integer
Dim varStr as String
'Initially Recorded: 2004-9-11 16:53:40
'Script Name: TestCom
StartBrowser "C:\Documents and Settings\Administrator\桌面\html.html", "WindowTag=WEBBrowser"
Window SetContext, "WindowTag=WEBBrowser", ""
Browser NewPage,"HTMLTitle=Combobox",""
'ComboBox Click, "Name=D1", ""
'ComboListBox Click, "Name=D1", "Text=2"
Result=SQAGetProperty("Type=ComboBox;Name=D1","innerText",varStr)
End Sub
以上脚本,返回值为innerText为1,2,3。这里要说明innerText返回值他是返回的是<p><select size="1" name="D1">
<option>1</option>
<option>2</option>
<option>3</option>
</select></p>
这段代码中select中下边中显示出来的关键字1,2,3。如果属性是outerHtml将是下边的属性值:<SELECT size=1 name=D1> <OPTION selected>1</OPTION> <OPTION>2</OPTION> <OPTION>3</OPTION></SELECT>
所以这说明robot识别combobox没有识别出来你的下拉选项!你可以通过一段代码就可以看出来,代码如下:
ComboBox Click, "Name=D1", ""
ComboListBox Click, "Name=D1", "Text=2"
针对这个问题,我们可以两个解决方法
1.纪录键盘移动!上下操作,可以设置属性!
2.下边的代码,可以是我针对我的网页实现combobox的,主要是针对selectindex属性设置
'$Include "sqautil.sbh"
Sub Main
Dim Result As Integer
Dim varStr as String
Dim List1Content() As String
'Initially Recorded: 2004-9-11 16:53:40
'Script Name: TestCom
StartBrowser "C:\Documents and Settings\Administrator\桌面\html.html", "WindowTag=WEBBrowser"
Window SetContext, "WindowTag=WEBBrowser", ""
Browser NewPage,"HTMLTitle=Combobox",""
Result = SQASetProperty ("Type=ComboBox;Name=D1", "SelectedIndex", "2")
if Result=sqaSuccess then
msgbox "ok"
else
msgbox result
end if
End Sub
[ Last edited by pcl2004_27 on 2004-9-11 at 17:55 ] |
|