1. Home
  2. Knowledge Base
  3. Ghostlab: Feature Reference
  4. QuickFills and QuickFill datasets

Quickfill and QuickFill datasets

QuickFills are a convenient way to fill out form fields. Basically, a QuickFill is a Shortcut code (e.g. $n) that triggers the execution of a JavaScript function when entered within a form field. The return value of the JavaScript function is then entered as the value of the form field. Consider the example below.


When you enter the trigger string “$n” when inside a form field, it will cause the function shown below to execute – it returns a random number between 0 and 100’000. The function receives the form field element ($element) as the first argument, in case you would need that to compute the desired return value. Ghostlab comes with several default QuickFills for numbers, emails, dates and others.

Note that since we have only introduced this feature in 2.1.3, your existing QuickFill codes will not automatically include the element as a function argument – you need to manually replace the first line “function()” with “function($element)”.

In some contexts, you may want to fill in different values in different browsers for the same QuickFill. For example, you might want to test your site by loggin in with multiple browsers, each with a different username/password combination. 

That’s why in Ghostlab 2.0.10, we’ve introduced Quickfill datasets. This allows you to define various sets of data which you can then use on your clients via the Quickfill feature. It can for example be used to define a set of login data for a site and then use that to log in different clients with different accounts.

Step 1 – Define your data

First, you have to define your data. This is done in the “Quickfill datasets” section of the preferences. You can add any number of datasets, name them any way you want, and then use the data editor to define the data. The data editor expects CSV-style input: define any number of columns separated by comma, and in whatever quantity (rows) you need. If your data contains commas, use quotes to group a column.

Important note: each row is considered a set, and each client will receive one full row. If you just define one row, all clients will receive the same row. If you define more than one row, they are distributed among client round-robin style – i.e. if you define 5 rows, and have 5 clients, each client will receive a distinct row.

At the bottom of the dataset section, you can choose which dataset is currently active. Set it to none if you don’t want any Quickfill data to be available on the clients.


Step 2 – Understand how your data can be used on the clients

Now that you have defined your datasets, you can use them on the clients. The data is available on the Ghostlab object, namely, as the array Ghostlab.state.quickFillData. In case you haven’t defined any data, or have set the active dataset to ‘None’, this will simply be an empty array. If there is data, then each column of the data row assigned to your client will be one of the Array’s items: Ghostlab.state.quickFillData[0], Ghostlab.state.quickFillData[1], etc.

The way to actually use the data are Quickfills. With the update to Ghostlab 2.0.10, we’ve added some default Quickfills ($0 – $4) that simply return the Quickfill data at the respective index (0,1,2,3,4). If you have defined, say, a dataset with 5 rows, each containing a username and a password, then you can use $0 to fill in the username in any form, and $1 to fill in the password. If you have enough rows for all the clients, then each client will input a different username and password. If you haven’t defined any data, the Quickfills will just return a string indicating that. We’ve included the Quickfills as examples, so feel free to explore this feature in any way and form you like!


Step 3 – Use data on the clients

The last step is to fire up the Ghostlab server, navigate to a page where you want to input your login (or any other) data, and trigger the Quickfill. We’re including a screenshot below, showing both Ghostlab with the Quickfill settings (triggers and data) and two clients just having used the Quickfill trigger $0.



Was this article helpful?

Related Articles