用Rational Functional Tester创建随需应变的自动测试脚本
2010-01-11 00:00:00 来源:WEB开发网改造后,回放过程中所需要用到的页面对象都是在当前浏览器中即时查找得到的。通过目标对象的类型和某个属性值来定位目标对象,脱离了"专用测试对象图"中树形结构的约束。SearchLotusLinkHelper的部分内容如下:
protected GuiTestObject document_htmlDocument() {
return new GuiTestObject(findTestObjectInBrowser(".class","Html.HtmlDocument",null,null));
}
protected TextGuiTestObject text_q() {
return new TextGuiTestObject(findTestObjectInBrowser(".class","Html.INPUT.text",".id","q"));
}
protected GuiTestObject button_search() {
return new GuiTestObject(findTestObjectInBrowser(".class","Html.INPUT.image",".value","Search"));
}
protected GuiTestObject link_httpWwwLotusCom() {
return new
GuiTestObject(findTestObjectInBrowser(".class","Html.A",".text","http://www.lotus.com/"));
}
protected TestObject findTestObjectInBrowser(String property1, String value1, String property2,
String value2)
{
TestObject[] foundTOs ;
//在当前浏览器页面中查找
if(null==property2)
foundTOs = browser_htmlBrowser().find(atDescendant(property1,value1)) ;
else
foundTOs = browser_htmlBrowser().find(atDescendant(property1,value1,property2,value2)) ;
//如果没有找到满足条件的TestObject
if(foundTOs.length<1)
{
throw new com.rational.test.ft.ObjectNotFoundException("Can NOT find TestObject with
"+property1+"<"+value1+">,"+property2+"<"+value2+">");
}
//如果找到多个TestObject满足条件,
else if(foundTOs.length>1)
{
throw new AmbiguousRecognitionException("Found multi-TestObject with
"+property1+"<"+value1+">,"+property2+"<"+value2+">");
}
//返回唯一的查找结果
return foundTOs[0];
}
Tags:Rational Functional Tester
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接