Editing datasets
After you data-drive a test to create a dataset or create an empty dataset, you can edit the records and variables in the dataset.
A dataset is a test dataset, a collection of related data records which supplies data values to the variables in a test script during test script playback. A record is a row in a dataset. A variable is a column in a dataset.
You can make the following changes to a dataset:
- Add, remove, move, or edit a row
- Add, remove, move, or edit a column
- Edit or clear cell(s)
- Cut, copy, or paste a cell, row, or column
Note: To have seamless access to a dataset CSV editor, you can use any one of the following web
browsers on Windows, Linux or Mac operating systems:
- Mozilla Firefox
- Google Chrome
- Microsoft Edge based on Chromium
Selecting a record
To select a record, you must click the column number. For example, 0, 1, or 2.
Adding a record
Removing a record
- Select a record that you want to delete.
- Click Remove Record.
Moving a record
To move a record before or after another record:
Editing dataset values
- Select the cell you want to change.
- Double-click the selected cell and type the new value of the cell.
Adding variables
Removing variables
- Right-click a cell in the variable you want to remove.
- Click Remove Variable.
Changing names, types, or move variables
Cutting, copying or pasting cells, records, or variables
To cut, copy, or paste a cell, a record, or a variable:
- To delete data in a cell, record, or variable to the clipboard and copy it to the clipboard, select a cell, a record, or a variable, right-click, and then click Cut.
- To paste the contents of the clipboard, select a cell, record, or variable that you want to overwrite with the contents of the clipboard, right-click, and then click Paste.
- To copy a cell, record, or variable to the clipboard, select a cell, a record, or a variable, right-click, and then click Copy.
Updating dataset values programmatically
You can also update the dataset values by using the getValue and setValue
APIs.
Use the following code sample to update the dataset in a test script from the required CSV
file.
public void testMain(Object[] args)
{
String cursorId= "differentTestCursor";
Cursor cursorOptions = Cursor.builder()
.cursorId(cursorId)
.accessMode(AccessModeEnum.OVERWRITE)
.fetchMode(FetchModeEnum.SEQUENTIAL)
.shareMode(ShareModeEnum.SHARED)
.lastActive(null)
.wrap(true)
.build();
//provide name of the dataset file as argument
Path path= Paths.get("setCellGetCell.csv");
String DatasetPath=path.toAbsolutePath().toString();
String DatasetEncodedPath = Base64.getEncoder().encodeToString(DatasetPath.getBytes());
DatasetCursor createdCursor= CursorFactory.getWorkbenchDatasetCursor("localhost", 7081,
DatasetEncodedPath, cursorOptions);
DatasetRow row= createdCursor.nextRow();
String ExistigValue=row.getValue("Column1");
System.out.println(ExistigValue);
logInfo(ExistigValue);
row.setValue("Column1", "Test");
String Newvalue=row.getValue("Column1");
System.out.println(Newvalue);
logInfo(Newvalue);
createdCursor.deleteCursor(true);
}
}