QTP - In web addin extensibility, can I use custom attributes to identify an object

We have developed a custom QTP add-on to automate Extjs application. We recently learned that the approach we used to develop the add-in is not reliable. We have used CSS classes rendered in the DOM tree to help QTP identify every object in the ExtJS application. Recently, our developer told us that this way of relying on CSS classes is a problem as these CSS classes keep changing. For example: in ExtJS web app, the login button control looks like this in the browser (just an outline, not exactly like below)

<a class = x-btn x-box-item x-btn-default-small id=button-1086 unselectable = on style = margin>
     <span class = x-something>
         <span class = y-something>Login</span>

      

So, in the xml config file for the custom addin, we wrote an identifier for a button like this

  <Conditions type="IdentifyIfPropMatch">
      <Condition prop_name="classname" expected_value="x-btn" is_reg_exp="true" />

      

We are using Javascript to extract the Input label present in the span tag above and assign it the title property of our custom Extjsbutton element . So when I record using QTP, the generated VBScript code is

         Browser("..").Page("..").Extjsbutton("Login").Click

      

In a recent release of the app, the button class name has changed from x-btn to x-fastbutton in the DOM. With this QTP, the button object cannot be identified.

We asked the application developer to give us a few new attributes for each control in the application that are persistent so that QTP can use them to identify every object in the application. The application developer gave us three new attributes and the new attributes look like this:

  <a id = 'button-123', class = 'x-button' , uft-xtype = Button, uft-isComponent = true, 
      uft-extclass = Ext.button.Button>

      

My question is if we can use these new attributes and their values โ€‹โ€‹directly in the "Condition" element in the xml config file, for example

   <Conditions type="IdentifyIfPropMatch">
      <Condition prop_name="uft-xtype" expected_value="button" is_reg_exp="true" />

      

Or Should I only use attributes that are registered in their own DOM, such as html id, filename, tag, in the Condition xml element for the toolbox.

One of our add-on developers used an external function call like the one below in the xml toolbox to demonstrate the use of these new attributes provided by the application developer.

             <Identification function="isExtjsButton">

      

But I learned from the QTP help file that using external function calls like this in the toolkit xml file will affect the performance of the add-in and should be avoided. I asked the developer to check if these custom attributes would be used directly in the condition element and to avoid calling an external function. But we couldn't crack it. Help on how to do this would be appreciated

Hello

Srinivas

+3


source to share


2 answers


finally contacted HP QTP support. They informed me that the custom attributes provided by the application developer must be part of the native DOM properties so that they can be used directly on the Condition element in the xml file. Since custom attributes are not part of the inline DOM, the only recourse is to use an external function call. Therefore, calling an external function is inevitable.



+2


source


Have you tried using Xpath-axis? I mean using stable IDs of the parent and fetching the dynamic ID while executing the desired object. In our case, we found that each object at some level was wrapped in a table with a stable identifier. You can develop similar logic based on your object chiarchies.

Logic like below:



	Set objTableName=Description.Create() ' Creating description object for Web Table
	' Setting the Web Table object properties to navigate to parent and then to child
	objTableName("micclass").value = "WebTable" 
	objTableName("class").Value="some-stable- part-in-the-table -class.*"
	objTableName("name").Value=strParentTableName
	' Check for the object existency and fetch the exact html ID for Dropdown List at run time
	If Browser("B").Page("P").Webtable(objTableName).Exist(gMaxTimeout)=True Then
		strTableText = Browser("B").Page("P").Webtable(objTableName).GetROProperty("outerhtml") 
	   	Set objRegEx = New RegExp   ' Create a regular expression.	   	
	   	objRegEx.Pattern = "ext-gen[0-9]+"
	   	objRegEx.IgnoreCase = True   ' Set case insensitivity.
	   	objRegEx.Global = True   ' Set global applicability.
	   	Set objMatches = objRegEx.Execute(strTableText)   ' Execute search.
	   	For Each objMatch in objMatches      ' Iterate Matches collection.
	   		strComboHtmlID = objMatch.Value
	   	Next	   
	   	Browser("B").Page("P").WebElement("html id:=" & strComboHtmlID ).Click ' Click on the Dropdown List
	   	'Check for Web element existency and performing click operation
	   	If Browser("B").Page("P").WebElement("innerhtml:=" & strValuetoBeSelected,"index:=1","class:=x-nowrap-combo-item").Exist(gMinTimeout) Then 
	   		Browser("B").Page("P").WebElement("innerhtml:=" & strValuetoBeSelected,"index:=1","class:=x-nowrap-combo-item").Click
      

Run codeHide result


0


source







All Articles