在脚本执行期间,有各种GUI对象,QTP与之交互.因此,了解关键GUI对象的基本方法非常重要,我们将能够有效地使用它们.
以下是我们在运行时间和减号期间访问文本框的方法;
设置 : 帮助测试人员将值设置到文本框中
单击 : 单击文本框
SetSecure : 用于安全地设置密码框中的文本
WaitProperty : 等待属性值变为真
存在 : 检查是否存在文本框
GetROProperty("text") : 获取文本框的值
GetROProperty("可见") : 返回布尔值,如果可见
Browser("Math Calculator").Sync Set Obj = Browser("Math Calculator").Page("SQR Calc").WebEdit("n") 'Clicks on the Text Box Obj.Click 'Verify if the Object Exist - Returns Boolean value a = obj.Exist print a 'Set the value obj.Set "10000" : wait(2) 'Get the Runtime Object Property - Value of the Text Box val = obj.GetROProperty("value") print val 'Get the Run Time Object Property - Visiblility - Returns Boolean Value x = Obj.GetROProperty("visible") print x
以下是一些可以使用Check Box : 的关键方法;
设置 : 帮助测试人员设置复选框值"ON"或"OFF"
点击 : 点击复选框.甚至检查ON或OFF,但用户无法确定状态
WaitProperty : 等待属性值变为真
存在 : 检查是否存在复选框
GetROProperty("name") : 获取复选框的名称
GetROProperty("可见") : 返回布尔值,如果可见
'To Check the Check Box Set Obj = Browser("Calculator").Page("Gmail").WebCheckBox("PersistentCookie") Obj.Set "ON" 'To UnCheck the Check Box Obj.Set "OFF" 'Verifies the Existance of the Check box and returns Boolean Value val = Obj.Exist print val 'Fetches the Name of the CheckBox a = Obj.GetROProperty("name") print a 'Verifies the visible property and returns the boolean value. x = Obj.GetROProperty("visible") print x
以下是一些可以使用单选按钮和减号的关键方法;
选择( RadioButtonName) : 帮助测试人员将收音机盒设置为"ON"
点击 : 单击单选按钮.甚至单选按钮ON或OFF但测试仪无法获得状态
WaitProperty : 等待属性值变为真
存在 : 检查是否存在单选按钮
GetROProperty("name") : 获取单选按钮的名称
GetROProperty("可见") : 返回布尔值,如果可见
'Select the Radio Button by name "YES" Set Obj = Browser("Calculator").Page("Forms").WebRadioGroup("group1") Obj.Select("Yes") 'Verifies the Existance of the Radio Button and returns Boolean Value val = Obj.Exist print val 'Returns the Outerhtml of the Radio Button txt = Obj.GetROProperty("outerhtml") print text 'Returns the boolean value if Radio button is Visible. vis = Obj.GetROProperty("visible") print vis
以下是一些可以使用组合框 : 号的关键方法;
选择(值) : 帮助测试人员从ComboBox中选择值
点击 : 点击对象
WaitProperty : 等待属性值变为真
存在 : 检查是否存在组合框
GetROProperty("Text") : 获取组合框的选定值
GetROProperty("所有项目") : 返回组合框中的所有项目
GetROProperty("项目计数") : 返回组合框中的项目数
'Get the List of all the Items from the ComboBox Set ObjList = Browser("Math Calculator").Page("Statistics").WebList("class") x = ObjList.GetROProperty("all items") print x 'Get the Number of Items from the Combo Box y = ObjList.GetROProperty("items count") print y 'Get the text value of the Selected Item z = ObjList.GetROProperty("text") print z
以下是一些可以使用Buttons : 的关键方法;
点击 : 点击按钮
WaitProperty : 等待属性值变为真
存在 : 检查Button的存在
GetROProperty("名称") : 获取按钮的名称
GetROProperty("已禁用") : 如果启用/禁用,则返回布尔值
'To Perform a Click on the Button Set obj_Button = Browser("Math Calculator").Page("SQR").WebButton("Calc") obj_Button.Click 'To Perform a Middle Click on the Button obj_Button.MiddleClick 'To check if the button is enabled or disabled.Returns Boolean Value x = obj_Button.GetROProperty("disabled") print x 'To fetch the Name of the Button y = obj_Button.GetROProperty("name") print y
在今天的基于Web的应用程序中,webTables变得非常普遍,测试人员需要了解WebTables的工作方式以及如何使用在webTables上执行操作.本主题将帮助您有效地使用webTable.
Sr.No. | 声明&说明 |
---|---|
1 | if语句 如果语句由一个布尔表达式后跟一个或多个语句组成. |
2 | 如果...... else语句 if else 语句由一个布尔表达式后跟一个或多个语句组成.如果条件为True.执行 if 语句下的语句.如果条件是假的. 其他脚本的一部分已执行 |
3 | if..elseif ... else语句 if语句后跟一个或多个 Elseif 语句,由布尔表达式组成,然后是可选的 else语句,当所有条件都变为false时执行. |
4 | 嵌套if语句 if或 elseif 语句在另一个 if 或 elseif 语句中(s). |
5 | 切换语句 开关语句允许对变量进行同等测试的列表价值. |
html id : 如果表格有id标签,那么最好使用此属性.
innerText : 表格的标题.
sourceIndex : 获取表的源索引
ChildItemCount : 获取指定行中存在的ChildItem的数量
RowCount : 获取表格中的行数
ColumnCount : 获取表格中的列数
GetcellData : 根据列和行索引获取单元格的值
Browser("Tutorials Point").Sync ' WebTable Obj = Browser("Tutorials Point").Page("VBScript Decisions").WebTable("Statement") ' Fetch RowCount x = Obj.RowCount print x ' Fetch ColumnCount y = Obj.ColumnCount(1) print y ' Print the Cell Data of the Table For i = 1 To x Step 1 For j = 1 To y Step 1 z = Obj.GetCellData(i,j) print "Row ID : " & i & " Column ID : " & j & " Value : " & z Next Next 'Fetch the Child Item count of Type Link in a particular Cell z = Obj.ChildItemCount(2,1,"Link") print z