October 6, 2011

Internal Displacement

Helix ALM
Although QA Wizard Pro supports a large number of third-party controls and technologies, there are always ones that our customers are working with that we haven't quite gotten to. This is where our .Net invocation technology can really come in handy. QA Wizard Pro’s .Net invocation allows you to call methods and access properties on .Net objects. This not only allows you to get at information that isn’t readily available to the user interface, but also to interact with controls that QA Wizard Pro doesn’t know about. There are four calls associated with this functionality: InvokeDotNETMEthod, InvokeDotNETMethodWithArgs, GetDotNETProperty, and SetDotNETProperty. The first two allow you to call methods on .Net objects and the second two allow you to retrieve and set properties of .Net objects. Recently, a customer was working with one of their applications that used Janus Grid, which we currently don’t have built-in support for. One of our team members was able to use .Net invocation to help the customer access and manipulate the grid. First, they wrote a series of wrapper functions to hide the rest of their script from these calls. The first, GetGridRows, takes the window name and the grid name (which was captured as a generic control by QA Wizard Pro) and returns the rows collection using the Janus grid method “GetRows”.
function GetGridRows(window, grid)
  rows = Window(window).Control(grid).InvokeDotNETMethod("GetRows")
  return rows
end function
After you have the rows collection, you can access a single row by index:
function GetRowByIndex(rows, rowIndex)
  row = rows.InvokeDotNetMethod("GetValue", rowIndex)
  return row
end function
Or get a cell by column name:
function GetCellByColumnName(row, columnName)
  cells = row.GetDotNETProperty("Cells")
  cellAtColumn = cells.InvokeDotNETMethod("get_Item", columnName)
return cellAtColumn
end function
And finally get and set cell values:
sub SetCellValue(row, cellAtColumn, valueToSet)
  row.InvokeDotNetMethod("BeginEdit")
  cellAtColumn.SetDotNETProperty("Value", valueToSet)
row.InvokeDotNetMethod("EndEdit")
end sub
function GetCellValue(cellAtColumn)
  cellValue = cellAtColumn.GetDotNETProperty("Value")
  return cellValue
end function
Using these simple helper functions, the customer could write complex scripts to automate the grid in their application. .Net invocation is an extremely powerful mechanism that allows you to extend QA Wizard Pro to do things and access controls we’ve never even heard of. Don't be afraid to use it to access the internals of your applications to create scripts that truly exercise every aspect of your system.