Log.WriteLine("Form Action is: " + Data("FormAction"))
If Data("FormAction") = "Add" Then
Me.ExecuteTest("User Access\FormAdd.tstest")
'Remove the dialog from the monitor
Manager.DialogMonitor.RemoveDialog(ad)
Else If Data("FormAction") = "Modify"
Dim formcell As HtmlTableCell = ActiveBrowser.Frames(0).Find.ByExpression(Of HtmlTableCell)("InnerText=" + Data("FormNumber"))
Log.WriteLine(formcell.ToString())
'Dim formcell As HtmlTableCell = ActiveBrowser.Frames(0).Find.ByExpression(Of HtmlTableCell)("InnerText=" + "PL 0002 0909")
Dim row As HtmlTableRow = formcell.BaseElement.Parent.[As](Of HtmlTableRow)()
Dim modifyBtn As HtmlInputButton = row.Cells(6).Find.ByExpression(Of HtmlInputButton)("value=Modify")
modifyBtn.Click()
'Remove the dialog from the monitor
Manager.DialogMonitor.RemoveDialog(ad)
Me.ExecuteTest("User Access\DeleteFormSchedule.tstest")
Me.ExecuteTest("User Access\FormDetail.tstest")
Else If Data("FormAction") = "Remove" Then
Dim formcell As HtmlTableCell = ActiveBrowser.Frames(0).Find.ByExpression(Of HtmlTableCell)("InnerText=" + Data("FormNumber"))
Log.WriteLine(formcell.ToString())
Dim row As HtmlTableRow = formcell.BaseElement.Parent.[As](Of HtmlTableRow)()
Dim removeBtn As HtmlInputButton = row.Cells(6).Find.ByExpression(Of HtmlInputButton)("value=Remove")
removeBtn.Click()
'ad.WaitUntilHandled(2000)
'Remove the dialog from the monitor
Manager.DialogMonitor.RemoveDialog(ad)
End If
The code that is used in the script is displayed above. I noticed that the script runs fine in most of the cases but when there are multiple iterations that have to run with atleast one Data("FormAction") = Modify and have to execute a subtest, I am getting an "object reference not set to an instance of an object"