Micro Focus QTP (UFT) Forums
RegEx in Object Identification - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: RegEx in Object Identification (/Thread-RegEx-in-Object-Identification)



RegEx in Object Identification - joncfrazier - 05-21-2012

Trying to store and click a link. This link can change and there can be similar links on the page (within the same column). How can I store the link value (i.e. save the current name of the link) and then click on it?

I've tried using "name:=[0-9]{6}" as a descriptive property value as well as using Record to find the link, and then add the same regex code into the name, outerhtml, and innerhtml descriptors.

None of this is working. Does anyone know how to find a dynamic link (or all of them that match), store it, and then click the link?

QTP 11
The link will always have 6 numeric digits.


RE: RegEx in Object Identification - petes85gt - 05-21-2012

I had a similar issue with clicking a links in a webtable. I ended up pulling the name from the cell (getroproperty), storing the name in a variable (or datatable), and I had a generic link object that I assigned that name to, so it would click on the correct link.


RE: RegEx in Object Identification - joncfrazier - 05-21-2012

Do you happen to have an example of how this would all work together?

I've only used GetROProperty once, and it was getting a top-level item (link name), not an item nested in a web-table.

Pretty sure I could get the storing part, at least to a variable if not a datatable.

I'm no sure what you mean by having a "generic link object" and attaching the getropropty to it.


RE: RegEx in Object Identification - petes85gt - 05-23-2012

'this is the column of the webtable that has the link in it - stored in the datatable
Code:
ncolumn = DataTable("Column_Testing", dtGlobalSheet)

'name of the link to click = cell value of top cell of testing column
'**********You may be able to substitute .getroproperty "name" (or whatever unique identifier) for getcelldata********
Code:
label = Browser("your browser").Page("your page").WebTable("Top Grid (date created and filter rows)").GetCellData(1, ncolumn)

'puts name of link in datatable
Code:
DataTable("Column_Name", dtGlobalSheet) = label

'name of column
Code:
Browser("your browser").Page("your page").Link("Column Name").Click
The last line is the generic link I was talking about. It is a link whose text property is the "Column_Name" of the datatable. All I have to do is put each column number in the datatable and it will automatically pull the name of the link from the first cell, and click the link with that name.

Basically this is an alternative to using regular expression and not exactly the same thing, so I am not sure if it will help. If you aren't using a table, you may be able to use getroproperty instead of getcelldata to get what you need.