Monthly Archives: October 2019

Download UFT script from ALM

Posted on by 0 comment

Usually we use ALM to manage our test cases, test script and resource files, which works very well, but when we consider to host the script in git, we have to download them to local and commit to git.

In this exercise, I try to download UFT scripts and resource files in UFT with using ALM OTA , the OTA api reference can be found here, and here is the code.

Dim locPath
locPath= "c:\uft\script" 


Function DownloadTestsFromALM(SaveToFolderPath)

	Dim qcCon, testList, testStorage
	Set qcCon= QCUtil.QCConnection 
	If qcCon.ProjectConnected Then 
		Set testFilter = qcCon.TestFactory.Filter
		testFilter.Filter("TS_TYPE") = "QUICKTEST_TEST"
		Set testList = qcCon.TestFactory.NewList(testFilter.text)
		For each t in testList 
			Set testStorage= t.ExtendedStorage 
	        testStorage.ClientPath= SaveToFolderPath&"\" & t.Field("TS_SUBJECT").Path & "\" & t.Name
			on error resume next
			testStorage.Load "Action0\*.*, Action1\*.*, Action2\*.*, Action3\*.*, Action4\*.*, Action5\*.*, default.cfg, default.usp, Default.xls,, Test.tsp, *.usr", True 
	        if Err.Number <> 0  then
	           reporter.ReportEvent micWarning, t.Field("TS_SUBJECT").Path & "\" & t.Name & " -- File download fFAILED. error:=" &  Err.Description,""
	           reporter.ReportEvent micPass, t.Field("TS_SUBJECT").Path & "\" & t.Name & " -- File download successful.", ""
	        end if
	End If
	Set qcCon= Nothing
	Set testList= Nothing
	Set testStorage= Nothing

End Function

Function DownloadResourceFromALM(SaveToFolderPath)
	Dim qcCon,CurrentResObj,ObjResFactory,ResObjList
	Set qcCon = QCUtil.QCConnection
	Set ObjResFactory = qcCon.QCResourceFactory
	Set ResObjList = ObjResFactory.NewList("")
	For each CurrentResObj in ResObjList 
		on error resume next
		CurrentResObj.DownloadResource SaveToFolderPath& "\" & CurrentResObj.path & "\" & CurrentResObj.Name,True

        if Err.Number <> 0  then
           reporter.ReportEvent micWarning, CurrentResObj.path & "\" & CurrentResObj.Name & " -- File download FAILED. error:=" &  Err.Description,""
           reporter.ReportEvent micPass, CurrentResObj.path & "\" & CurrentResObj.Name & " -- File download successful.", ""
        end if
	Set ResObjList = Nothing
	Set CurrentResObj = Nothing
	Set ObjResFactory = Nothing 
	Set qcCon = Nothing

End Function

Category: UFT

Firebase login in docker toolbox

Posted on by 0 comment

The exercise is trying to resolve the Firebase login callback issue in docker; my system setup is VirtualBox with Docker toolbox.
Let’s start with the login command:

# firebase login
Visit this URL on this device to log in:

Waiting for authentication…

Then I copy the long URL, and paste it to a browser window in host machine, allow the FirebaseCLI access, the authentication is working fine, but failed at callback. That is due to the setup is docker with VirtualBox, so localhost is not same as the docker machine, which in my case is, and HTTP://localhost:9005 is not accessible. If I try to modified the URL with replacing the localhost with docker machine IP, a 400 OAuth2 error will be returned.

Error: invalid_request
device_id and device_name are required for private IP:

After some trying, and managed to get it working with steps below,

  • Copy the long URL and paste it to a browser window in host machine
  • Follow the steps to complete the authentication
  • The callback failed with URL HTTP://localhost:9005?state=…..
  • Replace localhost with the docker machine IP in the URL and click enter

Now you will receive a successful message in the browser window and docker terminal.

Category: Docker