Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I specify an object with a randomly generated name?
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi,

What I'm trying to do is:

Code:
Dialog("Mywindow,  Provider ID = 762222,  Track ID = AAAA").WinButton("text:=New").Click

The problem is that Track ID is randomly generated each time, so it can not be found in the OR.

Then I read that properties are regular expressions, so I tried:

Code:
Dialog("text:=Mywindow,  Provider ID = 762222,  Track ID = ????").WinButton("text:=New").Click

And it couldn't find that either. (did I do my regexp wrong? Why didn't this work?)

Then I read that RegExpWndTitle is, 'The constant part of the window title.'

So I tried,

Code:
Dialog("RegExpWndTitle := Mywindow,  Provider ID = 762222,  Track ID =").WinButton("text:=New").Click

Because that is the constant part, right?

And that didn't work either. (Why not?)

So is there a way to fix one of my two attempts above, or is there a different method I should be using?

Thanks for any ideas,

Random
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Just to be clear, the actual name of the window is:

Code:
"Mywindow, Provider ID= 762222, Track ID = AAAA"

including the commas and the '=' signs. It is NOT supposed to be a list of properties, it is just a strange looking window name.

Maybe I should have said that I want to do this:

Code:
Dialog("WindowTitleXXXX").WinButton("text:=New").Click

The problem is that the 'XXXX' part of the name keeps changing.

So......any ideas?

Thanks,
Random
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
AND THE ANSWER IS!!!:

Code:
Dialog("text:=Mywin.*").WinButton("text:=&New").Click
So simple once you get it right!

The reasons this took me forever:
- you can have a space after the :=, but not before it, sometimes I had that wrong.
- ? does not replace a single char as I thought, actually that is '.'
- '.*' does replace any sequence of chars
- I don't know if RegExpWndTitle:= would have done it too, but text:= works, and I'm too tired of experimenting to find out if that was a problem.
- Sometimes I was using :=New, but the actual text was :=&New

Stupid little details can cause so much havoc...this is why I never want to be a programmer again...

Maybe I was talking to myself here...but in case anyone cared I thought I'd post the answer that drove me nuts for 2 days...

Random
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
This may have worked but a problem may arise when you have some other dialog box starting with the same text "Mywin".
Random generated IDs is a common situation encountered in QTP.

Here is what you should do in such situations-
  1. Try to find out the place where that ID is FIRST occurring in a particular session.
  2. Capture that ID in some variable
  3. Append that variable in your statement above
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#5
Solved: 11 Years, 3 Months, 4 Weeks ago
thanks for sharing the answer!!!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  UFT issues with Outsystems dynamically generated Id/names jherron 2 1,363 03-02-2020, 09:33 PM
Last Post: Swishy70
  Test runned from QualityCenter generated an error "Attempted to divide by zero." robertosalemi 1 2,569 10-14-2016, 08:38 PM
Last Post: robertosalemi
  Script is not generated for windows application in UFT sreelatha 1 2,379 04-04-2016, 10:51 AM
Last Post: vinod123
  Save randomly generated string SomeIntern 1 2,362 08-27-2013, 12:36 AM
Last Post: SomeIntern
  QTP does not recognise elements randomly Pkapoor 2 2,630 07-05-2013, 11:27 AM
Last Post: Pkapoor

Forum Jump:


Users browsing this thread: 1 Guest(s)