Micro Focus QTP (UFT) Forums
Dynamic Window Name in Winforms App - 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: Dynamic Window Name in Winforms App (/Thread-Dynamic-Window-Name-in-Winforms-App)



Dynamic Window Name in Winforms App - consumed85 - 11-04-2011

Hello,

I have this issue. I am trying to run a test on a window that changes names after every run. How can i get QTP to click on a tab on a window that's name is dynamic

Code:
SwfWindow("Dynamic name of window").SwfObject("tabStrip1").Click 275,11

ive tried
Code:
SwfWindow("regexpwndtitle:= NonDynamicPartOfName.*").SwfObject("tabStrip1").Click 275,11
- i saw this on another post but that did not work.

let me know if you need more information

Chris.


RE: Dynamic Window Name in Winforms App - ravi.gajul - 11-04-2011

Hi,
could you please post the obj spy snapshot of the window.

Regards,
Ravi


RE: Dynamic Window Name in Winforms App - Ankesh - 11-04-2011

Hi Chris,

First get the Window title

Code:
strTitle=SwfWindow("Dynamic name of window").GetROProperty("regexpwndtitle")

Now that u have the title, u can get the dynamic value which is changing each time. Split it. and store it in Some variable

strNewTitle=<NonDynamicPartOfName>&<Dynamic value which is changing>

'set the window title
Code:
SwfWindow("Dynamic name of window").SetTOProperty "regexpwndtitle",strNewTitle

now u can use your code.

Do let me know if it does not work.

Regards,
Ankesh


RE: Dynamic Window Name in Winforms App - consumed85 - 11-04-2011

Thanks for the reply Ankesh, The problem is that every time i run the app the object name of "SwfWindow("Dynamic name of window")" is never the same (except for the begining string which is static ex: Name: Dynamic Name) so how can i add an object to the OR if the objects name will change after i run the app again. Because i get an error that says cannot identify the object "Dynamic window Name" (of class SwfWindow) verify that this object's properties match an object currently displayed in your application


RE: Dynamic Window Name in Winforms App - Ankesh - 11-07-2011

Chris,

I guess only the name property of the object is dynamic which keeps changing. U can use regular expression for this property of the object( If not name then chk which property of the object is changing dynamically. Use regular expression for that property.)

Please refer to the attached document on how to use Regular expression for object in OR..
Attachment 1 -> Attachment 2.

I hope this would help.

Regatrds,
Ankesh