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.
|Run more learn more
What can be an alternate approach in case “OpenNewTab” function of webbrowser is not working
Note:-Please close all browsers before running the code, as we have used Creationtime property it might create a conflict in UFT mind.
Set obj =Browser("Creationtime:=0").WinObject("object class:=window")
obj.WinButton("acc_name:=New Tab (Ctrl+T)").Click
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)
'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
'Printing the separated values
for each val in arrNew
Based on the delimiter selected we would have different set of output values.
|Output results for varying delimiter
'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")
objP.WebList("wl_Test").Object.selectedIndex = iRand
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 browser in UFT
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.
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
|Options window in UFT
Try the following code before and after doing the changes and check the difference
'launch browser maximized
'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