Micro Focus QTP (UFT) Forums
How to identify a Dynamic WebElement? - 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: How to identify a Dynamic WebElement? (/Thread-How-to-identify-a-Dynamic-WebElement)



How to identify a Dynamic WebElement? - PreethiJoshi - 05-03-2018

I want to identify a web element (TIN Number) which is dynamic in nature. Every time the value is different. I used below code.  The innertext is not updating . How to identify innertext dynamically? I have attached object spy as well. Currently TIN value is "113482671" but will change in the next iteration. Please help!!


Code:
Public Function SelectTIN()
Dim obj
Set a=Description.Create
a("html tag").value = "A"
a("micclass").value="Link"
a("innerhtml").value= Datatable.value("TINNumber")
set obj = Browser("Micclass:=Browser").Page("Micclass:=Page").ChildObjects(a)
x= obj.count
For i=0 to x-1
obj(i).click
Next
SelectTIN = True
End Function

Code:
'..........Store TIN Number
Public Function StoreTINNumber()
TINNumber = Browser("1099 Detail DB").Page("1099 Detail DB").WebElement("ctl00$ContentPlaceHolder1$gvEd").GetROProperty("innertext")
DataTable.Value("TINNumber","Search Shared TIN")= TINNumber
StoreTINNumber = True
End Function


Code:
'............Get TIN Number
Public Function GetTINNumber()
Dim obj
Datatable.GetSheet("Search Shared TIN")
Set a=Description.Create
a("html tag").value = "A"
a("micclass").value="Link"
a("innerhtml").value= Datatable.value("TINNumber","Search Shared TIN") 'It will give value 00001545
set obj = Browser("Micclass:=Browser").Page("Micclass:=Page").ChildObjects(a)
x= obj.count
For i=0 to x-1
obj(i).click
Next
GetTINNumber = True
End Function



RE: Get Dynamic Innertext - Ankur - 05-03-2018

Using ChildObjects fetch the dynamic value of innertext and use that in a Descriptive programming statement.

You seem to be mixing two methods of writing Descriptive programming statements.

Here is the simplest way in your case to identify the webelement, (once you have fetched the value above).


Code:
Browser("micclass:=Browser").Page("micclass:=Page").WebElement("micclass:=Web Element","innertext:="&TIN).Click