April 13, 2011

Using a QA Wizard Pro Regular Expression to Select a ComboBox Item

Helix ALM

In QA Wizard Pro, you may need to select a specific item from a ComboBox but may only know partial information about the item. In cases like this, you can create a function and use a regular expression to select the item. In the following example, the FindItem function  takes a ComboBox LIST and uses pattern matching to find EXPR, which can be any valid regular expression. The regular expression allows you to select an item from a ComboBox.

  # 'FindItem function
Function FindItem(LIST,EXPR)
 LISTITEMS=Window("WysiCorp  Report a Bug").ComboBox(LIST).Property("ListItems")
 for X = 1 to NUM
  if EvaluateRegExpression(EXPR,LISTITEMS(X)) = true then
  end if
 return (-1)
End Function

In this example, we're searching the Product and Type ComboBoxes. The .*Chart regular expression  will match anything that ends in “Chart”,  and .*Function.* will match anything that contains the word “Function”. Remember that regular expressions are case sensitive.

Window("WysiCorp  Report a Bug").ComboBox("Product").Item(PRODUCT).Select()
Window("WysiCorp  Report a Bug").ComboBox("Type").Item(TYPE).Select()