Tips and Tricks for working with UFT?

Just for a change we tend to thought of attempting some out of way features offered in UFT.

We implemented the Runners logic:-i’m tired…i think i’ll opt for a run.
We were tired of sharing orthodox topics, so we thought lets share some less browse topics, Hope it motivates our followers to learn more and grow more

Do like our FB page, Twitter, or G+ for more learning.

Learn UFT
Run more learn more


What can be an alternate approach in case “OpenNewTab” function of webbrowser is not working

a)Using Native object method to open new tab.

Systemutil.Run "iexplore.exe",""
Browser("creationtime:=0").Object.Navigate "YAHOO.COM",Clng(&H800)

Note:-Please close all browsers before running the code, as we have used Creationtime property it might create a conflict in UFT mind.

b)Using Descriptiveprogramming

Systemutil.Run "iexplore.exe",""
Set obj =Browser("Creationtime:=0").WinObject("object class:=window")
obj.WinButton("acc_name:=New Tab (Ctrl+T)").Click
Browser("CreationTime:=1").Navigate ""
Set obj = Nothing

How to Split string in case we have inconsistent values of delimiter (We have taken space as a delimiter in our case, and we are not sure how many spaces separates consecutive words.)


sInput = "uftHelp=  User Firendly      Techy Help"
fn_SplitMe sInput," "
Public function fn_SplitMe(sTest,sDelimit)
Dim arrData
'Split the input string on the basis of Delimiter
arrData = split(sTest,sDelimit)
Dim arrNew():Dim j :j= 0
'Looping through all the elements to separate the Text and Delimiter
For iCnt = 0 to ubound(arrData)
If not arrData(iCnt) = "" Then
Redim Preserve arrNew(j)
arrNew(j) = arrData(iCnt)
j = j+1
End If
'Printing the separated values
for each val in arrNew
Print Trim(val)
End Function

Based on the delimiter selected we would have different set of output values.

Split function in UFT
Output results for varying delimiter 
Scenario 3:- 
How to select a random valuesfrom a weblist
Weblist select random values in UFT
Example Weblist
'Selecting a random value from the weblist 
Dim iRand :iRand = 0
'RandomNumber is a Utility Object,(1,103)specifies its
'lower & Upper range for generating random values
iRand = RandomNumber(1,103)
Dim objTest : Set objTest = ""
'Creating the main Browser object
Set objTest = Browser("CreationTime:=0").Page("Index:=0")
'Ist Approach
objP.WebList("wl_Test").Object.selectedIndex = iRand
'2nd Approach
objP.WebList("wl_Test").Select "#"&iRand

Scenario 4:-
How we can ignore a given browser or an ALM session when UFT is executing scripts.Suppose our requirement is to close all the browser before the run of test suite except ALM instance or “chrome” browser
Tools ->Options ->GUI Testing ->Web

Ignore ALM in Run UFT
Ignore browser in UFT

Browser details to ignore UFT
Browser Details 

Click on + symbol to add the browser details to be ignored, we can use title or URL of the browser.Also for ALM we can just select the option ignore ALM.

Scenario 5:-
How to change the run settings in UFT, so that it replicates the typing of keyboard on a webedit, rather than directly settings the value.

Requirement: – we want to type a value into a web edit on google search rather than putting all the value in one go.
Note: – WebEdit does not support the Type method, it is only present with window applications. We can implement send keys to achieve this but here we are focusing on UFT level settings to achieve the same.
Change the Replay Type to “Mouse” by using the path: – Tools->options->GUI Testing ->Web->Advance->Run Settings->Replay Type ->Mouse
Change replay type in UFT settings
Options window in UFT
Try the following code before and after doing the changes and check the difference

'launch browser maximized
SystemUtil.Run "chrome.exe","",,,3
'Create object of webedit
Set obj =Browser("creationtime:=0").Page("creationtime:=0").WebEdit("html id:=gbqfq")
'Setting value into Google search text box
obj.Set "This is really long text that we are writing to check the Type effect"

Keep learning and keep sharing

Leave a Reply

Your email address will not be published. Required fields are marked *