我正在尝试使用QTP 11.0 Web可扩展性插件在对象识别下显示自定义Web元素类型。
我的扩展程序中有四个文件,如问题末尾所示。我的问题是没有任何对象出现在Object Identification
窗口中。我以为我可能做错了,所以我加载了SDK附带的GWT
示例,但它也没有在对象标识中显示任何内容!
QTP是否保留日志或任何类型的调试信息,说明我可能遇到的错误类型,或者是否按预期工作,这些自定义对象甚至不会假设显示在对象识别窗口中?如果是这样,为什么?
$INSTALLDIR\dat\Extensibility\Web\HiddenTestObjects.xml
<?xml version="1.0" encoding="UTF-8"?>
<TypeInformation Load="true" AddinName="Web" PackageName="Hidden" DevelopmentMode="true" priority="1">
<ClassInfo Name="Hidden" BaseClassInfoName="WebElement" GenericTypeID="object" DefaultOperationName="Set" FilterLevel="0">
<Description>Input field of type="hidden".</Description>
<TypeInfo>
<Operation ExposureLevel="CommonUsed" Name="Set" PropertyType="Method">
<Description>Sets the content of the value attribute.</Description>
<Documentation><![CDATA[Enter %a1 in the %l hidden field.]]></Documentation>
<!-- The text to enter in the box. If this argument is not provided, the box is cleared. -->
<Argument Name="text" IsMandatory="false" Direction="In">
<Type VariantType="String"/>
</Argument>
</Operation>
</TypeInfo>
<IdentificationProperties>
<IdentificationProperty ForDefaultVerification="true" ForVerification="true" ForDescription="true" Name="value"/>
<IdentificationProperty ForDefaultVerification="false" ForVerification="false" ForDescription="true" Name="html tag" ForOptionalSmartID="true" OptionalSmartIDPropertyValue="1"/>
<IdentificationProperty Name="html id" ForDefaultVerification="false" ForVerification="false" ForDescription="false"/>
<IdentificationProperty Name="innerhtml" ForDefaultVerification="false" ForVerification="false" ForDescription="false"/>
<IdentificationProperty Name="innertext" ForDefaultVerification="false" ForVerification="false" ForDescription="false" ForOptionalSmartID="true" OptionalSmartIDPropertyValue="2"/>
<IdentificationProperty Name="outerhtml" ForDefaultVerification="false" ForVerification="false" ForDescription="false"/>
<IdentificationProperty Name="outertext" ForDefaultVerification="false" ForVerification="false" ForDescription="false"/>
</IdentificationProperties>
</ClassInfo>
</TypeInformation>
$INSTALLDIR\dat\Extensibility\Web\Toolkits\Hidden\Hidden.xml
<?xml version="1.0" encoding="UTF-8"?>
<Controls xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Settings>
<Variable name="common_file" value="HiddenCommon.js"/>
</Settings>
<JSLibrariesToInject>
<JSLibrary path="INSTALLDIR\bin\JSFiles\jQuery-1.3.2.js" />
<JSLibrary path="INSTALLDIR\bin\JSFiles\jQuery.simulate.js" />
</JSLibrariesToInject>
<Control TestObjectClass="Hidden">
<Settings>
<Variable name="default_imp_file" value="Hidden.js"/>
</Settings>
<Identification>
<Browser name="*">
<HTMLTags>
<Tag name="input"/>
</HTMLTags>
<Conditions type="IdentifyIfPropMatch">
<Condition prop_name="type" expected_value="hidden" is_reg_exp="false" equal="true"/>
</Conditions>
</Browser>
</Identification>
<Record>
<EventListening use_default_event_handling_for_children="true" use_default_event_handling="true" type="javascript" function="ListenToEvents"/>
</Record>
<Run>
<Methods>
<Method name="Set" function="Set"/>
</Methods>
</Run>
<Filter>
<Spy is_control_spyable="Yes"/>
<Learn learn_children="No" learn_control="Yes"/>
</Filter>
</Control>
</Controls>
$INSTALLDIR\dat\Extensibility\Web\Toolkits\Hidden\Hidden.js
/////////////////////////////////////////////////////////////////////////
// Hidden.js
//
// This file contains the implementation of the support for Hidden input controls.
//
/////////////////////////////////////////////////////////////////////////
var HIDDEN_CATEGORY = 7;
function get_property_value(property) {
if (property == "logical name") {
return "Hidden";
}
if (property == "type") {
return "hidden";
}
if (property == "value") {
return window.$(_elem).value;
}
if (property == "disabled") {
return false;
}
}
function Set(text) {
preventReplayOnDisabledControl("Set");
// NULL or empty text string can be used to clear the text area.
// Convert both to an empty string.
window.$(_elem).value = (text != null? text : "");
var reportParams = new Array(text);
_util.Report(micDone, "Set", toSafeArray(reportParams), "Set the following text:" + text);
return true;
}
function ListenToEvents(elem) {
return true;
}
$INSTALLDIR\dat\Extensibility\Web\Toolkits\Hidden\HiddenCommon.js
/////////////////////////////////////////////////////////////////////////////////
// HiddenCommon.js
//
// This file contains shared JavaScript functions that can be called by functions
// in other JavaScript files in the Hidden toolkit support set.
//
/////////////////////////////////////////////////////////////////////////////////
function HTMLElemArrayToString(HTMLElemArray)
{
var ElemArrayAsString = new Array();
for (var i = 0; i < HTMLElemArray.length; i++)
{
ElemArrayAsString.push(window.$(HTMLElemArray[i]).text());
}
return ElemArrayAsString.join(";");
}
function preventReplayOnDisabledControl(action) {
if (get_property_value("disabled")) {
_util.Report(micFail, action, toSafeArray(new Array()), "Cannot Replay On Disabled Control");
throw "Cannot Replay On Disabled Control";
}
}
function shouldIgnoreEvent(eventObj) {
if (get_property_value("disabled")) {
return true;
}
if (eventObj.button && eventObj.button != QtpConstants.LEFT_BUTTON()) {
return true;
}
return false;
}
答案 0 :(得分:1)
QTP从 HiddenTestObjects.xml 文件中获取用于对象识别的属性。在那里,您可以指定哪个属性是 ForDescription 和智能标识(请查看架构或文档以获取更多详细信息)。
QTP允许通过对象识别对话框在机器到机器的基础上覆盖这些设置,但AFAIK的假设是Web可扩展性作者最了解应该使用哪些属性。
如果您认为让用户覆盖您在 HiddenTestObjects.xml 中列出的对象识别规则很重要,则应该向HP打开增强请求。否则,我所知道的唯一方法是指示用户在本地编辑 HiddenTestObjects.xml 。