Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
want to change index dynamically of WebTable object
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
need a urgent help.

I am new to QTP.I am facing a problem about object identification in QTP.

When i add a standard checkpoint.
the code is generated like
Code:
Browser("Application").Page("Application").Frame("main_Frame").WebTable("Security").Check CheckPoint("Security")


QTP can identify the WebTable object uniquely using Ordinal Identifier Type - Index and it's value.
But when if any development on this application, value of Index of WebTables are changed.
So Check Points related to the webtable are failed.
So i have to modify Index value of webtables after every new deployment.
so is it possible to set the index dynamically or any other approach which can avoid this problem.

If possible Please let me know how to do that.

Thanks in Advance...
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Atanu,

First thing is check and choose the properties that can identify the object unique in different builds/application versions.

Second option : dynamic handling of the index value of the webtable.
Code:
Dim intCounter : intCounter = 0
Browser("Application").Page("Application").Frame("main_Frame").WebTable("Security").SetToProperty "index", intCounter
Do Until Browser("Application").Page("Application").Frame("main_Frame").WebTable("Security").Exist = True
     intCounter = intCounter + 1
     Browser("Application").Page("Application").Frame("main_Frame").WebTable("Security").SetToProperty "index", intCounter
Loop
Please let me know if you need any information.
Thanks,
SUpputuri
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi supputuri,

First option is not possible in this application as there is no unique object properties.
Second option, When i execute this code,the loop condition is never true.
So loop is not stopped.
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Atanu,

Try using descriptive programming to find all of the web tables with name "Security". This code searches frame "main_frame" for all web tables with the name "Security". "children.count", in the code below, is the number of such tables found. Then you can loop through the tables found, one by one, and do whatever you want. Maybe this will do what you want or give you some more ideas on how to solve your problem.

Tim

Code:
oDesc=Description.Create
oDesc("micclass").Value="WebTable"
oDesc("Name").Value="Security"
set children=Browser("Application").Page("Application").Frame("main_Frame").ChildObjects(oDesc)
for i = 0 to children.count - 1
    'here you can use children(i) to get properties, etc. e.g., children(i).GetROProperty("abs_x")
    'or children(i).click, etc. whatever you want to do with the web table found
next i
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks both for your reply.It helps to find out the solution.
Now I have solved this problem by two ways

1> Using regular Expression and runtime object Property(Without changing the index)

The code is like this,

Code:
Set obj = Description.Create
    obj("micclass").Value = "WebTable"
    obj("html tag").Value = "TABLE"
    obj("inner text").Value = "Security CodeLedger Category.*"
    Set objCol =   Browser("Application").Page("Application").Frame("mainFrame").ChildObjects(obj)    
    runtimename= objCol(1).GetROProperty("name")
    runtimeabs_x=objCol(1).GetROProperty("x")
    Browser("Application").Page("Application").Frame("mainFrame").WebTable("Security Code").SetToProperty "name", runtimename
    Browser("Application").Page("Application").Frame("mainFrame").WebTable("Security Code").SetToProperty "x", runtimeabs_x
    Browser("Application").Page("Application").Frame("mainFrame").WebTable("Security Code" ).Check CheckPoint("Security Code")

2> Change the WebTable index dynamically

The code is like this,

Code:
Set obj = Description.Create
    obj ("micclass").Value = "WebTable"
    obj ("html tag").Value = "TABLE"
    obj ("innertext").Value = "Security CodeLedger Category.*"
    Set objCol =   Browser ("Application").Page("Application").Frame("mainFrame").ChildObjects(obj)  
      If  iCount <> 0 Then
           Set  table2use=objCol.item(iCount-1)
     Else
          Msgbox ( "cound not find the table")
      End If

HeaderTableIndex= GetQTPTableIndex (table2use)
dataTableIndex=headerTableIndex
Browser("Application").Page("Application").Frame("mainFrame").WebTable("index:=" & dataTableIndex).Check CheckPoint("Security Code")

Function GetQTPTableIndex(TableObj)
         On Error Resume Next
         Set TableObj = TableObj.Object
         On Error Goto 0

        srcIndex = TableObj.sourceIndex
        Set domDocument = TableObj.document.documentElement
        Set allTables= domDocument.getElementsByTagName("TABLE")
         i = 0
        For each table in allTables
           If table.sourceIndex = srcIndex Then
             GetQTPTableIndex = i
             Exit Function
          End If
        i = i + 1
       Next
End Function
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
I am very new to QTP and VB script

Can you please explain the logic you have applied inside the function GetQTPTableIndex in index method

Also what is purpose of below condition and from where is iCount coming?
Code:
If iCount <> 0 Then
Set table2use=objCol.item(iCount-1)
Else
Msgbox ( "cound not find the table")
End If

Thanks in advance!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do you Change Run mode mid script? Caleytown 6 7,191 03-25-2021, 08:27 AM
Last Post: RB26578
  UFT issues with Outsystems dynamically generated Id/names jherron 2 1,346 03-02-2020, 09:33 PM
Last Post: Swishy70
  Unable to capture value of Webelement which is changing dynamically sheetal 9 16,208 02-16-2018, 11:01 AM
Last Post: janki_kakadia
  Unable to click on dynamically changing webelement preeti 0 1,807 04-29-2017, 08:50 PM
Last Post: preeti
  click each web link in a page using Index or other method in QTP smeijer 13 24,675 04-29-2017, 04:53 PM
Last Post: kowshik

Forum Jump:


Users browsing this thread: 1 Guest(s)