Help Index

HP UFT Website

How does it work?

Via HTTP POST over SSL. Your Testuff login details are used for identification. Each test has a unique ID. Test results are POSTed to the relevant API URL and include – as parameters – the test ID, lab name, and test result. Following the request, Testuff updates the test result accordingly.

Read more about the automation url on the Automation page.

UFT integration know-how

Pre Requisites:

  1. UFT should be installed on execution machine.
  2. Testuff URL, Login ID and Password.
  3. Testuff automation test ID to be stored in variable in UFT Test.

Steps:

  1. Open UFT test
  2. Download function library ReportToTestuff.vbs
  3. Add the function library to UFT. file -> Settings ->Resources
  4. Call function ReportToTestuff(Auto_Test_Id) at the end of UFT test and pass automation test ID from variable.

If UFT test is executed successfully and UFT result is “Passed” or “Done”, the test status is reported as “Passed” in Testuff and if UFT result is “Failed”, the test status is reported as “Failed” in Testuff.

Sample

Manual Test Case:
To Navigate through each link available on http://www.testuff.com

  • Step 1: Open Internet Explorer and navigate to http://www.testuff.com
  • Step 2: Verify if “About Us” link exists and click on “About Us” link
  • Step 3: Verify if “Products” link exists and click on “Products” link
  • Step 4: Verify if “Screen Shots” link exists and click on “Screen Shots” link
  • Step 5: Verify if “Download” link exists and click on “Download” link
  • Step 6: Verify if “Purchase” link exists and click on “Purchase” link
  • Step 7: Verify if “Support” link exists and click on “Support” link

UFT Test:

Auto_Test_Id = "ID" ' Testuff Automation Test ID

'Test Step 1
Systemutil.Run ("/")

'Test Step 2
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=About").Exists
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=About").Click

'Test Step 3
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=Products").Exists
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=Products").Click

'Test Step 4
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=Screenshots").Exists
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=Screenshots").Click

'Test Step 5
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=Download").Exists
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=Download").Click

'Test Step 6
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=Purchase").Exists
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=Purchase").Click

'Test Step 7
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=Support").Exists
Browser("Name:=Software Test Management").Page("Name:=Software Test Management").Link("Name:=Support").Click

' Call Function to Report Run Status to Testuff

ReportToTestuff(Auto_Test_Id)

Notes:

  1. The Script can be Enhanced further as per the project needs and various Test Status.
  2. Further Extension could be a UFT-Testuff Keyword Driven Framework

Function: ReportToTestuff vbs code

Function ReportToTestuff(s_test_id)
Dim strXML
'XML request string
Dim strJSON
'JSON request string
Dim strUserName
'user name to connect to the Web API service
Dim strUserPassword
'password for the user to connect to the Web API service
Dim strWebAPIURL
'Web API service URL
Dim s_expected_status, s_steps_failed, s_comment
' set Web API connectivity parameters
' replace email, password and serviceX with your account details
strUserName = "youremail@domain.com" ' <----Change
strUserPassword = "bbaaK0c2fbu" ' <----Change
strWebAPIURL = "https://serviceX.testuff.com/api/v0/run/" ' <----Change https://serviceX.testuff.com/api/v0/run/
' set test scenario parameters
 
var_RunStatus = Reporter.RunStatus ' UFT Reporter
If var_RunStatus= "0" Then
s_status = "passed"
End If
If var_RunStatus= "1" Then
s_status = "failed"
End If
If var_RunStatus= "2" Then
s_status = "passed"
End If
 
's_steps_passed = "3"
's_steps_failed = "2,4"
's_comment = "additional info"
'prepare Web API call data
strJSON = "{" & _
EmbraceInQuotes("test_id") & ":" & EmbraceInQuotes(s_test_id) & "," & _
EmbraceInQuotes("status") & ":" & EmbraceInQuotes(s_status) & "," & _
EmbraceInQuotes("steps_failed") & ":" & EmbraceInQuotes(s_steps_failed) & "," & _
EmbraceInQuotes("steps_passed") & ":" & EmbraceInQuotes(s_steps_passed) & "," & _
EmbraceInQuotes("comment") & ":" & EmbraceInQuotes(s_comment) & _
"}"
' Try JSON Request '---------------------------------
strResult = GetDataFromURL(strWebAPIURL, strUserName, strUserPassword, "POST", "application/json", strJSON)
End Function
 
Function EmbraceInQuotes(str)
Dim res
res = Chr(34) & str & Chr(34)
EmbraceInQuotes = res
End Function
 
Function GetDataFromURL(strURL, strLogin, strPassword, strMethod, strContentType, strPostData)
Dim lngTimeout
Dim intSslErrorIgnoreFlags
Dim blnEnableRedirects
Dim blnEnableHttpsToHttpRedirects
Dim strHostOverride
Dim strResponseText
Dim objWinHttp
Const CREDENTIALS_FOR_SERVER = 0
lngTimeout = 59000
intSslErrorIgnoreFlags = 13056
' 13056: ignore all err, 0: accept no err
blnEnableRedirects = True
blnEnableHttpsToHttpRedirects = True
strHostOverride = ""
Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
objWinHttp.SetTimeouts lngTimeout, lngTimeout, lngTimeout, lngTimeout
objWinHttp.Open strMethod, strURL
If strMethod = "POST" Then
objWinHttp.setRequestHeader "Content-type", strContentType
End If
If strHostOverride <> "" Then
objWinHttp.SetRequestHeader "Host", strHostOverride
End If
objWinHttp.Option(4) = intSslErrorIgnoreFlags
objWinHttp.Option(6) = blnEnableRedirects
objWinHttp.Option(12) = blnEnableHttpsToHttpRedirects
objWinHttp.SetCredentials strLogin, strPassword, CREDENTIALS_FOR_SERVER
On Error Resume Next
Print "Post Data here" & strPostData
objWinHttp.Send(strPostData)
Print "Sreenu Error Desc" & Err.number
If Err.Number = 0 Then
If objWinHttp.Status = "201" Then
GetDataFromURL = "Created: " & objWinHttp.GetResponseHeader("Location")
Else 
	GetDataFromURL = "Error: " & objWinHttp.ResponseText
	print "Got Error " & GetDataFromURL
End If
Else
GetDataFromURL = "Error " & Err.Number & " " & Err.Source & " " & Err.Description
print "Got Error " & GetDataFromURL
End If
On Error GoTo 0
Set objWinHttp = Nothing
End Function

Help Index