3

I am trying to get custom Web element types to show up under Object Identification using QTP 11.0 Web Extensibility Add-Ins.

add-in manager showing gwt and hidden

I have four files in my extension as shown at the end of the question. My problem is that none of the objects show up in the Object Identification window. I thought I might be doing something wrong, so I loaded the GWT sample that comes with the SDK, but it doesn't show anything in Object Identification either!

Does QTP keep a log or any sort of debugging information about what kind of error I might have, or is it working as intended and these custom objects aren't even supposed to show up in the Object Identification window? If so, why?

object identification window showing nothing

$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;
}
allquixotic
  • 1,481
  • 2
  • 18
  • 37

1 Answers1

1

QTP gets which properties to use in object identification from you HiddenTestObjects.xml file. In there you can specify which property is ForDescription and smart identification (check the schema or documentation for more details).

It would be nice for QTP to allow overriding these settings on a machine to machine basis via the object identification dialog but AFAIK the assumption was that the web extensibility author knows best which properties should be used.

If you feel it's important to let users override the object identification rules you set forth in HiddenTestObjects.xml you should open an enhancement request with HP. Otherwise the only way I know of is to instruct users to edit HiddenTestObjects.xml locally.

Motti
  • 110,860
  • 49
  • 189
  • 262
  • So you're saying that the web extensibility test classes just *won't* ever appear in Object Identification, but they will appear when you capture a Shared Object Repository? I just need them to show up in the SOR, I don't need to let the user customize which properties are selected. I thought there was an error because they don't show up in Object Identification. – allquixotic Aug 18 '13 at 00:54
  • @somequixotic, yes that's what I'm saying (I may be wrong of course). Did you try learning them? – Motti Aug 19 '13 at 08:18