3

QTP 11.0 Web Extensibility Add-Ins を使用して、カスタム Web 要素タイプを Object Identification の下に表示しようとしています。

gwt と非表示を表示するアドイン マネージャー

質問の最後に示されているように、拡張機能には 4 つのファイルがあります。Object Identification私の問題は、ウィンドウにオブジェクトが表示されないことです。何か間違っているのではないかと思いGWT、SDK に付属のサンプルをロードしましたが、Object Identification にも何も表示されません。

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 にとって良いことですが、私の知る限りでは、Web 拡張機能の作成者がどのプロパティを使用すべきかを最もよく知っていると想定されていました。

HiddenTestObjects.xmlで設定したオブジェクト識別規則をユーザーがオーバーライドできるようにすることが重要であると思われる場合は、HP に機能強化のリクエストを提出してください。それ以外の場合、私が知っている唯一の方法は、ユーザーにHiddenTestObjects.xmlをローカルで編集するように指示することです。

于 2013-08-17T19:48:31.703 に答える