Before you begin, create the ActiveData asset that contains the data that you want to use or that you want to write data to.
Map the data from the ActiveData asset to the script that you want to use. Additionally, you can add rows or columns to the ActiveData asset, and add data to the ActiveData asset from the script.
Public Sub Main() With _desktop.BrowserWindow("/BrowserApplication//BrowserWindow") .DomTextField("@id='txtFirstName'").SetText("Pat") .DomTextField("@id='txtLastName'").SetText("Smith") .DomTextField("@id='txtPhoneNumber'").SetText("555-121-3434") .DomButton("@id='btnAdd'").Select() End With
Workbench.LoadActiveData("activeDataName", [start row, end row, randomcount, readonly])
Public Sub Main() AddAllToPhoneBook() 'Reads all records in order End Sub Public Sub AddAllToPhoneBook() Dim data As ActiveData = Workbench.LoadActiveData( "PhoneBookData" ) Dim row As ActiveDataRow With _desktop.BrowserWindow("/BrowserApplication//BrowserWindow") For Each row In data Dim FirstName As String = row.GetString("fname") Dim LastName As String = row.GetString("lname") Dim PhoneNumber As String = row.GetString("phonenumber") .DomTextField("@id='txtFirstName'").SetText(FirstName) .DomTextField("@id='txtLastName'").SetText(LastName) .DomTextField("@id='txtPhoneNumber'").SetText(PhoneNumber) .DomButton("@id='btnAdd'").Select() Next End With End SubWhen you playback the script, all the declared data from the ActiveData asset is included in the script.
Public Sub Main() AddColumnToDataFile( "occupation" ) End Sub Public Sub AddColumnToDataFile( name As String ) Dim data As ActiveData = Workbench.LoadActiveData( "PhoneBookData" ) data.AddColumn( "Occupation", name ) data.Save() End Sub End ModuleWhen you playback the script, the new column is added to the file specified by the ActiveData asset.
Public Sub Main() InsertNewNumberToDataFileWithOccupation( 108, "Jay", "Jones", "5551219", _ "QA Analyst" ) End Sub Public Sub InsertNewNumberToDataFileWithOccupation( id As Integer, _ firstName As String, lastName As String, phoneNumber As String, _ occupation As String ) Dim data As ActiveData = Workbench.LoadActiveData( "PhoneBookData" ) Dim row As ActiveDataRow = data.AddRow() row.SetLong( "id", id ) row.SetString( "fname", firstName ) row.SetString( "lname", lastName ) row.SetString( "number", phoneNumber ) row.SetString( "occupation", occupation ) data.Save() End Sub End ModuleWhen you playback the script, the new row is added to the file specified by the ActiveData asset.
Dim row As ActiveDataRow = data.Item(1) row.SetString("Columnname" , Variable)