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


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

HI Raj,
I have move forwarded with your answer. Now I am able to store the "alt" Property of Yellow Icon in to Data table.
But QTP not clicking on the Yellow Icon Image.

I am using the following Code:

Code:
Dim MyConnection, ConnectionString

Set MyConnection = CreateObject("ADODB.Connection")
ConnectionString = "Provider=sqloledb; Data Source=Ramesh; Initial Catalog=midc390;User Id=sa;Password=sa@123"
MyConnection.Open(ConnectionString)

Set MyRecordSet = CreateObject("ADODB.Recordset")
MyRecordSet.ActiveConnection=MyConnection
MyRecordSet.Open(""Select ID, NumID from Costestimate as YellowIcon where ReqID= '"&p&"'")

If  MyRecordset.EOF <> True  Then
    DataTable.Value("YellowIcon") = MyRecordset.Fields("YellowIcon").Value
End If

Dim Imglink
Imglink = DataTable.Value("YellowIcon")

Browser("Information Management").Page("Information Management").Frame("Frame_\d").Image("alt:="&Imglink).Click

I Even tried the Below Code also:-

Code:
Set oDesc = Description.Create()
      oDesc("abs_x").Value = "830"
      oDesc("abs_y").Value = "305"
      oDesc("html tag").Value = "IMG"
      oDesc("file name").Value="yellow_arrow\.gif"
      oDesc("alt").Value="Imglink"

Browser("Information Management").Page("Information Management").Frame("Frame_\d").Image(oDesc).Click
Set oDesc = nothing

But I am Getting this Error:
Cannot identify the object "[ Image ]" (of class Image). Verify that this object's properties match an object currently displayed in your application.


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

Code:
MyRecordSet.Open("Select ID, NumID from Costestimate as YellowIcon where ReqID= '" &p& "'")



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

Hi Ankur,
Can you please help me in this. I am able to get the value => javascript:OpenEstimate(8770,1,2,3452) in to datatable and i stored the same in to a variable, But QTP not clicking on the Yellow Icon.
Getting the above mentioned error.


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

Hi Ankur,
Can you provide any help in this? I am eagerly waiting.


RE: QTP throws error on web elements when Descriptive programing used. - Saket - 08-08-2011

does the value which you get in datasheet after querying the db matches with what you see in alt properties of your image?

also in your earlier code I can see you have done wrongly
oDesc("alt").Value="Imglink"

it should be
oDesc("alt").Value=Imglink




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

Hi Saket,
I changed the script as per your suggestion.
Still i am unable to click on Image

Code:
Code Changed as Below:
Set oDesc = Description.Create()
oDesc("abs_x").Value = "830"
oDesc("abs_y").Value = "305"
oDesc("html tag").Value = "IMG"
oDesc("alt").Value=Imglink
                
Browser("Works Information Management").Page("Works Information Management").Frame("Frame_\d").Image(oDesc).Click
Set oDesc = nothing

I even tried by removing double quotes for other properties also.

I am attaching the screen shot contains Application Information & the result

Any help is appreciated.


RE: QTP throws error on web elements when Descriptive programing used. - hariraman.g - 08-09-2011

Hi,

I have a question, if the alt tag is unique for all the images, there is no need of giving their x and y co-ordinates.

Try by giving

Code:
Set oDesc = Description.Create()
oDesc("html tag").Value = "IMG"
oDesc("alt").Value=Imglink

Browser("Works Information Management").Page("Works Information Management").Frame("Frame_\d").Image(oDesc).Click



RE: QTP throws error on web elements when Descriptive programing used. - parminderdhiman84 - 08-09-2011

Hello,

Frames create a lot of problem in object identification. I faced many myself untill i got a solution. And here it is, you don't need to use frames in your script. Just remove the frame from code as well as Object Repository.

e.g. use
Code:
Browser("Works Information Management").Page("Works Information Management").Image(oDesc).Click

Hope this solves your problem (atleast it did mine)

Regards,
Parminder


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

HI Hariraman,
I followed the same steps as you mentioned, But it not worked.
But one thing i want to say alt property is not unique for all Yellow Icons.

Hi Parminder,
I shifted all the objects from frame to page in OR, Now all steps executed successfully but only the YellowIcon click step is not working.
I am getting the same error message as mentioned above.

I am also attaching the screen shot of New OR.


RE: QTP throws error on web elements when Descriptive programing used. - parminderdhiman84 - 08-10-2011

Hi,

In the Object spy on the previous page, i can see that image is in webtable. So i would suggest you to use childitem method in Webtable to click the image instead of creating description of image.

to do so>> add the webtable to your repository. take the rowcount. loop through rowcount and on the desired row, click on the image using childitem method.

please let me know if you face any problem in this approach.

Regards,
Parminder