Micro Focus QTP (UFT) Forums
QTP throws error on web elements when Descriptive programing used. - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: QTP throws error on web elements when Descriptive programing used. (/Thread-QTP-throws-error-on-web-elements-when-Descriptive-programing-used)

Pages: 1 2 3


QTP throws error on web elements when Descriptive programing used. - nistalaramesh - 11-19-2010

If I record in QTP-10 for clicking on a web tab page I am getting the below type of code.
Code:
Browser("Works Information Management").Page("Works Information Management").Frame("Frame").Link("Cost Estimate").Click

But Frame is Dynamic & name changes always as Frame_1, Frame _2….etc.

I changed the code as below using Spy
Code:
Browser("title:=Works Information Management System").Page("title:=Works Information Management System").Frame("micclass:=Frame").Link("title:=Cost Estimate").Click

I am getting error while executing.

I even tried below code:
Code:
Browser("title:=Works Information Management System").page("title:=Works Information Management System").Frame("micclass:=Frame").webtable("column names:=Add New Work;").Link("innertext:=Cost Estimate").WebElement("innerhtml:=Cost Estimate").Click

I am attaching the error Screen Shot & Spy screen

Please help me ASAP.


RE: QTP throws error on web elements when Descriptive programing used. - KavitaPriyaCR - 11-19-2010

Hi Ramesh,

Try this script once, please let me know if you get any errors.
Code:
set desc=Description.create()
desc("micclass").value="WebTable"
desc("name").value="Add New Work"    ' Edit here if name is different
'Add more values incase if exists for the table

Set WebEdits=Browser("title:=Works Information Management System").page("title:=Works Information Management System").ChildObjects(desc)
rCount=WebEdits(0).rowCount
'WebEdits(0) here 0 is used to access the first webtable, change it if  different table
For r=1 To rCount-1
    cCount=WebEdits(0).columnCount(r)
    For c=1 To cCount-1
        oCount=WebEdits(0).ChildItemCount(r,c,"Link")
        obj=1 To oCount-1
        If (StrComp(WebEdits(0).ChildItem(r,c,"Link",obj).GetROProperty("innertext"),"Cost Estimate")=0) Then
            WebEdits(0).ChildItem(r,c,"Link",obj).Click
        End If
    Next
Next



RE: QTP throws error on web elements when Descriptive programing used. - ngocvo3103 - 11-19-2010

Hi Ramesh,

For this problem, you can try catching the changing rule of the frame name, and use regular expression for it. For example:

You can use this regular expression: ^Frame_\d+$ to match these frame names:
Frame_1
Frame_2
Frame_9999999
...

Regards,
Ngoc Vo


RE: QTP throws error on web elements when Descriptive programing used. - nistalaramesh - 11-19-2010

Hi Kavita,
The solution is not working as it is displaying syntax error. Also I am new to QTP. Actually it is a web tab page not a link. Also I am having same Issue in the Cost Estimate page which contains an Image and it's name changes continuously. I parametrized as mentioned above but it is not working.

I am also attaching the code for this.

Code:
Browser("Works Information Management").Page("Works Information Management").Frame("Frame").Link("Cost Estimate").Click
Browser("Works Information Management").Page("Works Information Management").Frame("Frame_2").Image("javascript:OpenEstimate(8770,1").Click

It changed from Image("javascript:OpenEstimate(8770,1") to Image("^javascript:OpenEstimate(\d+$")

After parametrization in Object Repository the code changed automatically but not working.
I even tried Image("javascript:OpenEstimate(.*")

I turn on smart identification also before running the script.
Please help me.


RE: QTP throws error on web elements when Descriptive programing used. - nistalaramesh - 11-25-2010

Can Anybody help me for my situation


RE: QTP throws error on web elements when Descriptive programing used. - mvuyy001 - 11-25-2010

Hi
Can you please check if the Frame has any unique property such as a name/title or any value in the innertext or innerhtml that you can use for handling the dynamic frame. Look for unique properties on both Identification/Native properties secton of the Object Spy.

Thanks
MV


RE: QTP throws error on web elements when Descriptive programing used. - nistalaramesh - 11-26-2010

I am attaching the screen shot for my problem. Also i am attaching the Object spy screen shot.
Please help me In this regard.


RE: QTP throws error on web elements when Descriptive programing used. - manishbhalshankar - 11-30-2010

Hi,

Use filename and index property to identify your image object and for frame use html tag, html id, title if these are not changing.


RE: QTP throws error on web elements when Descriptive programing used. - nistalaramesh - 07-29-2011

HI,
The file name property didn't worked as 2 similar Icons present in the page. I am also not found Index property in the Spy.

Please help me on this.

I found another solution for the problem but i don't have idea on doing this. Need Help on this.
I can get the value (8770,1) from database query ==> ("javascript:OpenEstimate(8770,1")

My Situation is as below
first i have to get a value from Text Box 'x/xxx/xxxx' and i have to store some where, I am storing that in data table or i can store in a variable (ExTongue) ==> This i achieved and i am able to store the value in variable p or in datatable.

Later on I have to fire a query in the database and should pass the value in to Query => Select ID, NumID from Costestimate where ReqID= 'P'
Then i can get the value => (8770,1)
Then i have to do descriptive programming to click on the Yellow Icon.
Please help me on my Situation. By providing the code. My database is SQLServer

I Don't know how to do but i tried this after that please help me

Code:
Dim MyConnection, ConnectionString
Set MyConnection = CreateObject("ADODB.Connection")
ConnectionString = Provider=sqloledb; Data Source=Ramesh; Initial Catalog=ProdDB;User Id=sa;Password=sa@123
Set MyRecordSet = CreateObject("ADODB.Recordset")
MyRecordSet.Open "Select ID, NumID from Costestimate where ReqID= 'P' "

But how can i pass P(value) in to that Query
and i have to get the Database query result in to the QTP application
and i have to concatenate the rest of the string(javascript:OpenEstimate) to that value,
Then i have to click on the Yellow Icon


RE: QTP throws error on web elements when Descriptive programing used. - rajpes - 07-29-2011

q="Select ID, NumID from Costestimate where ReqID= '"&p&"'"

MyRecordSet.Open q