代码:
'前提:进入51论坛-个人中心,点击“论坛个性化设定”
With browser("51Testing软件测试论坛 软件测试 -").Page("51Testing软件测试论坛 软件测试 -")
'step1--校验选择界面风格
DataTable.Value("界面风格","weblist&webradiogroup")="discuz6"
tvalue1=datatable.Value("界面风格","weblist&webradiogroup")
.WebList("界面风格").Select tvalue1
actvalue1=trim(.WebList("界面风格").GetROProperty("selection"))
DataTable.Value("界面风格","weblist&webradiogroup")="使用默认"
tvalue2=datatable.Value("界面风格","weblist&webradiogroup")
.WebList("界面风格").Select tvalue2
actvalue2=trim(.WebList("界面风格").GetROProperty("selection"))
If actvalue1=tvalue1 and actvalue2=tvalue2 Then
reporter.ReportEvent micPass ,"step1","passed"
else
reporter.ReportEvent micPass ,"step2","failed"
End If
End With
With browser("51Testing软件测试论坛 软件测试 -_2").Page("51Testing软件测试论坛 软件测试 -")
'step2--选择其他选项,这里不做校验
.WebRadioGroup("每页主题数").Select "30"
.WebRadioGroup("每页帖数").Select "15"
.WebRadioGroup("签名显示设置" ).Select "1"
.WebRadioGroup("头像显示设置" ).Select "2"
reporter.ReportEvent micDone ,"step2 doesn't checked",""
'step3--校验时差设定选择某个特定值,及随机选择某个值
expect="(GMT -10:00) Hawaii" '对应的index值是3
.WebList("时差设定").Object.selectedIndex = "3"
actual=trim(.WebList("时差设定").GetROProperty("selection"))
If actual = expect Then
reporter.ReportEvent micPass ,"step3","passed"
else
reporter.ReportEvent micFail ,"step3","failed"
End If
'获取list下具体有几个选项
itemcount=.WebList("时差设定").GetROProperty("items count")
tvalue3=RandomNumber(0,itemcount-1)
.WebList("时差设定").Object.selectedIndex = tvalue3
reporter.ReportEvent micDone ,"随机选择的index:"&tvalue3&"",""
End With
知识点:
1.DataTable.Value("界面风格","weblist&webradiogroup")="discuz6":给”界面风格“列赋值,注意第二个参数也需要双引号括起来
2.调用封装属性items count的属性值从而获取weblist下具体有几个选项
3.RandomNumber(x,y):随机获取x到y之间的一个值