Tips and Tricks for working with UFT? – User friendly Tech help

Just for a change we tend to thought of attempting some out of way features offered in UFT.
n
nWe implemented the Runners logic:-i’m tired…i think i’ll opt for a run.
nWe 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
n
nDo like our FB page, Twitter, or G+ for more learning.
n

n

n

n

n

n

n

n

n

Run more learn more

n

@PhotoCourtsey
n
nScenario1:-
nWhat can be an alternate approach in case “OpenNewTab” function of webbrowser is not working

n

a)Using Native object method to open new tab.

n

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

n

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

nb)Using Descriptiveprogrammingn

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

n

n
nScenario2:-
nHow 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.)

n

nCode:-

n

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
Next
'Printing the separated values
for each val in arrNew Print Trim(val)
Next
End Function

n

nOutput:-
nBased on the delimiter selected we would have different set of output values.

n

n

n

n

n

n

n

n

Output results for varying delimiter 

n

Scenario 3:- 
nHow to select a random valuesfrom a weblist

n

n

n

n

n

n

n

n

Example Weblist

n

'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

n

 

n


Scenario 4:-

n

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

n

Step1:–

n

Tools ->Options ->GUI Testing ->Web

n

n

n

n

n

n

n

n

Ignore browser in UFT

n

n

n

n

n

n

n

n

Browser Details 

n

Step2:-

n

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.

n

Scenario 5:-

n

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.

n

Requirement: – we want to type a value into a web edit on google search rather than putting all the value in one go.

n

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.

n

Approach:-

n

Change the Replay Type to “Mouse” by using the path: – Tools->options->GUI Testing ->Web->Advance->Run Settings->Replay Type ->Mouse

n

n

n

n

n

n

n

n

Options window in UFT

nTry the following code before and after doing the changes and check the difference
n
n

'launch browser maximized
SystemUtil.Run "chrome.exe","google.com",,,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"

n

n
nKeep learning and keep sharing

n

More Learning Scenarios

Was this article helpful?
YesNo

Similar Posts