About Me

Gaurav Seth is a a Senior Automation Test Analyst with experience in QTP, Selenium and Ranorex tools and currently working on Automating in C# for a FX trading Client

Java Table - Select a Row

Following snippet of code will select a Row in a Java Table using Regular Expressions. It will search for rows where allercalm medicine has been prescribed and select this row

rows=JavaWindow("SystmOne GP: VNISThreeTester").JavaTable("View").GetRoProperty("rows")
cols=JavaWindow("SystmOne GP: VNISThreeTester").JavaTable("View").GetRoProperty("cols")
For i =0 to rows-1
data=JavaWindow("SystmOne GP: VNISThreeTester").JavaTable("View").GetCellData(i,"Drug")
searchval="allercalm"
Dim ObjRegExp
Set ObjRegExp=new regexp
ObjRegExp.pattern=searchval
ObjRegExp.Global=True
ObjRegExp.IgnoreCase=True
Set matches=ObjRegExp.Execute(data)
For each objmatch in matches
tmpVar=objmatch.value
If searchval=tmpVar Then
JavaWindow("SystmOne GP: VNISThreeTester").JavaTable("View").SelectRow(i)
Exit For
End If
Next
Next