Thursday, August 13, 2020

Right tool for a righteous purpose - kapwing!

While the world is struggling with the pandemic and uncertain times, we started hearing news of another, less spoken but widely felt pandemic that was brewing under lock-downs and limited mobility. Combined with the economic uncertainties and strained relationships for a few and loneliness for others, the depleting mental health pandemic is also creating major issues all around the world.

Myself, and a friend of mine, have been listening to a world renowned mystic, Sadhguru, regularly. It is incredible how just listening to him at regular intervals, we have had experienced tremendous mental clarity, peace, calm and a sense of well being. Thankfully, this is not the usual positive speaking humdrum, but a truly empowering and clarifying content.

Both of us grew up speaking different languages. I spoke Gujarati and she spoke Chinese. One day we just realized that how many people could be benefited by these simple sessions if they were able to understand the content.

She decided to create the English transcript and translate it to Chinese, while I decided to support someone who can do the translation service to Gujarati. Having worked in technology for a long time, I was confident about finding some tool that will enable me to add these subtitles to the videos.

I tried a couple of desktop tools and multiple online tools. I am going to avoid their names, since it is inconsequential. Because the difference is staggering and instinctive. When I opened the link https://www.kapwing.com, I was not sure what to think of it. I was trying to get something done so I just decided to go for it.

Creating an account was very simple, but just linking it to my gmail account. I logged in a I was ready to launch into my first project. 

It has a simple interface and workspace view.


Immediately, I was able to find the Subtitler and get started. The best thing I loved right away was a very clean layout. There is a small video display on the top left where we can view the video as well as control it, either by clicking on the video itself or on the controls to the right.

The text edit options are right below the video and immediately show effect when changed on the video itself.

The 'set to current time' and the arrow keys for finer time adjustments, were the most utilized controls by me. In fact, once you get accustomed to the interface, the work gets done, really fast. I have done 5 min videos in about 15 - 20 min, with very precise results.

The Create button at the bottom right finishes the job and delivers a high quality output video, which can be used multiple ways as shown below.

 

I would definitely ask you to go experience the interface. The feeling of a smooth operation, the intuitiveness, simplicity and accuracy of the controls make the work delightfully easy with a high quality result.

I have used the Studio feature as well to trim the video and import it straight to the Subtitler for editing. I don't think I will switch to another tool for at least these needs. I look forward to explore the other features that they have available.

I would like to extend my heartfelt gratitude to the entire kapwing team and to give them credit for enabling us to make a difference in people's lives, when it matters most.

Friday, April 22, 2016

Executing Powershell commands through TestComplete

Powershell is an extremely powerful toolbox and the ability to use it through TestComplete adds a whole new dimension to efficiently automating testing and related activities.

Here is a VBScript example of what you might do using TestComplete and Powershell.

Library function to execute Powershell command:

FUNCTION lib_run_pwsh_cmd(ByVal pre_cmd, ByVal psh_cmd)
  DIM wsh : SET wsh = CreateObject("WScript.shell")
  DIM launch_pshell : launch_pshell = "powershell.exe -noexit -ExecutionPolicy ByPass"
  DIM final_pshCommand : final_pshCommand = launch_pshell & " " & pre_cmd & ";" & psh_cmd & ";exit"
  Log.Message("PShell command : " & final_pshCommand)
  r = wsh.run(final_pshCommand,,true)
END FUNCTION


The launch_pshell command fires up the powershell command window with a -noexit flag which means the window will stay open after the execution is done. I choose to do that so in case something doesn't go right, I can see the output in the window to debug.

The pre_cmd is any powershell command that I need to execute before doing the actual operation. e.g. change directory to a particular location i.e. cd "C:\TC11Projects"

the psh_cmd is the actual powershell command/script that I want to execute. e.g. GenerateData.ps1 -data_descriptor "US_PHONE_NUMBERS"

This executes the script GenerateData.ps1 and passes the argument for the data_descriptor parameter.

The final_pshCommand shows what is called command chaining in command line execution which means it executes all the commands separated by ';' one after the other.

The 'exit' command in the end exits powershell.

Here is how I would call the above Function:

SUB TestPowershellFunction
DIM preCmd, pshCmd
preCmd = "cd C:\TC11Projects"
pshCmd = "GenerateData.ps1 -data_descriptor 'US_PHONE_NUMBERS'"
CALL lib_run_pwsh_cmd(preCmd,pshCmd)
END SUB


Wednesday, March 2, 2016

Creating testing Deliverables using TestComplete 2 - Test Log

TestComplete gives plenty of features to log the progress and significant outcomes of a test run using Logging in TestComplete.

To add to this functionality and have a customized deliverable at the end of every test run, I customized logging to log to a text file the progress and results from my test run.

Here is a VBScript sample.
'--------------------------------------------------------------------------------------
'LOG FILE UTILTIES
DIM theLogFile

FUNCTION Log_Start(ByVal msg_start, ByVal filePath)
  CALL lib_CreateFile(filePath)
  SET theLogFile = lib_OpenFileForWriting(filePath)
  theLogFile.WriteLine(now & vbTab & "INF" & vbTab & msg_start)
END FUNCTION

FUNCTION Log_End(ByVal msg_end)
  CALL Log_Write("INFO",msg_end)
  theLogFile .Close
END FUNCTION

FUNCTION Log_Write(ByVal Msg_Type, ByVal Msg)
  SELECT CASE UCASE(Msg_Type)
    CASE "INFO"
      theLogFile.WriteLine (now & vbTab & "INF" & vbTab & Msg)
    CASE "WARNING"
      theLogFile.WriteLine (now & vbTab & "WRN" & vbTab & Msg)
    CASE "ERROR"
      theLogFile.WriteLine (now &  vbTab & vbTab & "ERR" & vbTab & vbTab & Msg)   
    CASE "SUCCESS"
      theLogFile.WriteLine (now & vbTab & vbTab & "SCS" & vbTab & vbTab & Msg)
    CASE "BREAK"
      theLogFile.WriteLine (Msg)
    CASE ELSE
      Log.Error("Could not recognize message type:" & Msg_Type)   
  END SELECT
END FUNCTION

'--------------------------------------------------------------------------------------

The functions  lib_CreateFile and  lib_OpenFileForWriting are library functions I wrote that use the VBScript FileSystemObject to create a file and open the file for writing text respectively. Here is the documentation for that.

Here is how I use the function and how the log file looks like which I submit when asked, "What did/does your automation test test?"

FUNCTION Login
' Log into the website
 CALL Log_Write("INFO", "Logging into the webpage")
IF LoginSuccess THEN
 CALL Log_Write("SUCCESS", "Logging into the webpage")
ELSE
 CALL Log_Write("ERROR", "Logging failed")
END IF
END FUNCTION

I keep track of passed and failed test cases and log them too along with a final testing status at the end

Sample Log file created:

11/11/2015 8:34:39 AM    INF    LOGGING START : 11/11/2015 8:34:39 AM
11/11/2015 8:34:40 AM    INF    <<<<<<< TEST CASE >>>>>>>
11/11/2015 8:34:40 AM    INF    Test Identifier:     CardActivation_01-ActivateCard_ValidSrNo_FD
11/11/2015 8:34:40 AM    INF    >>>>>>> TEST CASE >>>>>>>
11/11/2015 8:35:38 AM    INF    STEP::Verifying if displayed page is :LoginHome
11/11/2015 8:35:41 AM        SCS        STEP::Verifying if displayed page is :LoginHome
11/11/2015 8:35:41 AM    INF    Access: Logout from the VTS website
11/11/2015 8:35:46 AM    INF    STEP::Verifying if displayed page is :Home
11/11/2015 8:35:48 AM        SCS        STEP::Verifying if displayed page is :Home
11/11/2015 8:35:48 AM        SCS        Access: Logout from the VTS website
11/11/2015 8:35:48 AM    INF    REPORT:##### CURRENT TEST CASE REPORT #####
11/11/2015 8:35:48 AM    INF    REPORT:Test Complete : True
11/11/2015 8:35:48 AM    INF    REPORT:Test Passed : True
11/11/2015 8:35:48 AM    INF    REPORT:# of Test Steps : 3
11/11/2015 8:35:48 AM    INF    REPORT:# of Test Points Passed : 3
11/11/2015 8:35:48 AM    INF    REPORT:# of Test Errors Found : 0
11/11/2015 8:35:48 AM    INF    REPORT:#####    FINAL TEST STATUS    #####
11/11/2015 8:35:48 AM    INF    REPORT:Test:CardActivation_01-ActivateCard_ValidSrNo_FD:COMPLETE ; PASSED.
11/11/2015 8:35:48 AM    INF    REPORT##### END TEST STATUS #####
'
'
'
11/11/2015 8:37:15 AM    INF    -----------------------------------------------------------------
11/11/2015 8:37:15 AM    INF    ##### FINAL #####
11/11/2015 8:37:15 AM    INF    ##### TEST REPORT #####
11/11/2015 8:37:15 AM    INF    REPORT:: Total Tests Run = 2
11/11/2015 8:37:15 AM    INF    REPORT:: Pass/Fail Ratio = 2/0
11/11/2015 8:37:15 AM    INF    REPORT:: Total Test Points = 8
11/11/2015 8:37:15 AM    INF   ######################################################
11/11/2015 8:37:15 AM    INF    LOGGING END : 11/11/2015 8:37:15 AM

Tuesday, March 1, 2016

Creating testing Deliverables using TestComplete 1 - Browser Images

Here is what I use to create deliverables after I finish an automated testing.

1) Having screenshots to submit for a web application.

I created this library routine Click_Picture that takes a picture of the entire browser screen(even parts that are not currently visible on the screen) and stores them at a desired location.

1) picNum starting from 1000 helps sort the pictures in the folder in the order it was taken. You can use/change/discard it as you desire.

2)  fldrPath_TestRun is a folder I create at the beginning of each test to save any files related to my current test run.

3) strPicName is a short descriptor for the picture that is being taken. A convention I use is 'B' means before and 'A' means after. e.g.
'A_Login' means after login
'B_SubmitForm' means before submitting the form.


 4) PagePicture is a method that TestComplete provides to capture a complete image of the tested object.

5) lib_FileCopy is any library function that can copy the picture from where TestComplete saves it to the desired folder.


DIM picNum: picNum = 1000

DIM fldrPath_TestRun

fldrPath_TestRun = "C:\TC11Projects\03012016_103216AM"

PUBLIC FUNCTION Save_PagePicture(ByVal strPicName)

  DIM src_Path, dest_Path
  picName = picNum & "_" & TRIM(strPicName)

  src_Path = Log.Picture(Sys.browser.Page("*").PagePicture, "Saving page picture")                                              
    dest_Path = fldrPath_TestRun & "\" & picName & ".png"                                               
    CALL lib_FileCopy(src_Path, dest_Path)
    Log.Message("SAVED PICTURE:")
    Log.Message(dest_Path)

END FUNCTION

Monday, February 22, 2016

Log monitoring using TestComplete (Windows example)

TestComplete provides excellent all round test automation features. Some AUT (application under test) might be writing to log files. Validation of those log entries or kicking off particular tests when certain log entries are observed might become necessary.
While TestComplete allows file handling using the scripting language libraries, here is one way of using more relevant utilities to do the work and make things efficient.

Example:
Monitor a text log file till you come across an error line (with work "Error"). When that happens send an email to a particular address notifying the recipient of the error.

1) Use windows PowerShell to monitor the log:
We can use TestComplete to kick off a PowerShell prompt and have it run the command to tail an existing log file.

Get-Content C:\temp\myLog.txt -Tail 1 -Wait | select-string -pattern 'Error' | Out-File C:\temp\flagError.txt

The above statement monitors the tail end of the log file myLog.txt for a string that matches a pattern error. When the latest file entry is written, if it contains text Error (case insensitive), it will create a file flagError.txt with that entire string. for e.g. If the last line added says 'Error: File not found' then this string will be written into the flagError.txt

VBScript Example:
FUNCTION monitor_LogTail(ByVal checkWord, ByVal filePath_Log)
  DIM wsh : SET wsh = CreateObject("WScript.shell")
  DIM launch_pshell : launch_pshell = "powershell.exe -noexit -ExecutionPolicy ByPass"

  DIM monitorCommand : monitorCommand = """Get-Content " & filePath_Log & " -Tail 1 -Wait | select-string -pattern '" & checkWord & "' | Out-File C:\temp\flagError.txt"""
  DIM final_pshCommand : final_pshCommand = launch_pshell & " " & monitorCommand
  Log.Message("PShell command : " & final_pshCommand)
  r = wsh.run(final_pshCommand,,true)
END FUNCTION


SUB tst_LogMonitor
  CALL monitor_LogTail("Error", "C:\temp\myLog.txt")
END SUB


2) After kicking off the above command in the shell, TestComplete can be used to monitor the folder 'C:\temp' for the existence of the file flagError.txt

3) As soon as the file get's created, the shell prompt is closed from TestComplete

4) Open the file flagError.txt if we need the error string in TestComplete.  If we don't need the error string, the file's creation signals what we are looking for in the log.

5) Delete the file flagError.txt. Continue processing next set of instructions in the test.


Tuesday, February 2, 2016

Connecting to Oracle Database from VB Script

Recently while trying to connect to an Oracle DB using VBScript within TestComplete, I ran across the error "Oracle client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Versi on 7.3.3 or later client software installation."

I was using the following code:

FUNCTION test_sql
DIM ado_Connection, ado_RecordSet
SET ado_Connection = CreateObject("ADODB.Connection")

SET ado_RecordSet = CreateObject("ADODB.Recordset")
Dim strSQLQuery: strSQLQuery = "SELECT * FROM ABC where rownum < '2'"
Dim strDBDesc: strDBDesc = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=11.1.111.111)(PORT=1521)))(CONNECT_DATA=(SID=DB_QA)))"
Dim strConnection:strConnection = "Provider=OraOLEDB.Oracle;Data Source=" & strDBDesc & ";User ID=uid;Password=pwd;"
 

ado_Connection.ConnectionString = strConnection

ado_RecordSet.Open strSQLQuery, ado_Connection, adOpenForwardOnly, adLockReadOnly, adCmdText
 

'Process Recordset obtained

END FUNCTION


These are the steps I used to 'finally' (phew!) get it to work.

TestComplete uses 32 bit ODBC libraries.

1) Download and unzip to any directory
 ODAC121024Xcopy_32bit.zip

2) Open the readme.html and follow instructions to install 'all' components and then add the the install directory and the install directory's bin subdirectory to the system PATH environment variable.

3) Open the 32 bit ODBC data source administrator from 'C:\Windows\SysWOW64' (file:odbcad32.exe)

4) Click Add

5) Find 'Microsoft ODBC for Oracle' and it.

Run the above code. It works









Thursday, January 28, 2016

Automation Testing Framework

https://prezi.com/y1b2igrhyozt/fat/

Email me if you have any questions.