Micro Focus QTP (UFT) Forums
How do I create a generic function to get Page Titles? - 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: How do I create a generic function to get Page Titles? (/Thread-How-do-I-create-a-generic-function-to-get-Page-Titles)



How do I create a generic function to get Page Titles? - donnajm - 08-24-2011

I wanted to write a function to get page titles and pass it to return variable that I can use for the script when verifying the page title name. Is there syntax to also write the result to a file so I can find out if the variable value is correct or not.

Plus I want to do the same for Brower().Page(), etc. I started it, I do not know what to do from here. I used to write automation in C# and I was able to find and replace a variable from a function to pass it to the next set of code.

' *****************************
' Name: GetPageTitle
' ****************************
Code:
Function GetPageTitle(pageTitleName)
pageTitleName = Browser("CreationTime:=0").Page("title:=.*").GetROProperty("title")
return pageTitleName
End Function
' ******************************


RE: How do I create a generic function to get Page Titles? - suresz449 - 08-24-2011

Instead of using Browser("CreationTime: = 0) use Browser("CreationTime: = .*)


RE: How do I create a generic function to get Page Titles? - donnajm - 08-24-2011

Thank you so much, how do you pass the variable to the next step or action: Browser("whatever").Page("whatever")......etc. What is the syntax to replace "whatever"?

Also how do you write the results of the variables to a log file so I can use it for troubleshooting? Thanks again