3

我正在尝试使用 QTP 11.0 Web Extensibility Add-Ins 让自定义 Web 元素类型显示在对象标识下。

显示 gwt 和隐藏的加载项管理器

如问题末尾所示,我的扩展名中有四个文件。我的问题是Object Identification窗口中没有显示任何对象。我想我可能做错了什么,所以我加载了GWTSDK 附带的示例,但它也没有在对象识别中显示任何内容!

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;
}
4

1 回答 1

1

QTP 从HiddenTestObjects.xml文件中获取要在对象识别中使用的属性。在那里,您可以指定哪个属性是ForDescription和智能标识(查看架构或文档以获取更多详细信息)。

QTP 允许通过对象识别对话框在机器对机器的基础上覆盖这些设置会很好,但 AFAIK 的假设是 Web 可扩展性作者最清楚应该使用哪些属性。

如果您认为让用户覆盖您在HiddenTestObjects.xml中规定的对象识别规则很重要,您应该向 HP 提出增强请求。否则,我知道的唯一方法是指示用户在本地编辑HiddenTestObjects.xml

于 2013-08-17T19:48:31.703 回答