1. Home
  2. Knowledge Base
  3. Ghostlab: Features
  4. Filling out forms

Filling out Forms

Ghostlab can help you filling out forms quickly and effectively in various ways. When you start filling out a form manually on any connected client, Ghostlab will synchronize these events as any others, resulting in the form being filled out on all clients in the same way.

While filling out forms, you can either use the Automatic form filling feature to fill the entire form with random values (you can fully configure how these values are generated in JavaScript functions). Or you can use the Quickfill shortcuts that will randomly populate the field currently in focus (e.g. $e for a random E-mail address). As an alternative to filling the form with identical values across clients, you can use the Remote form filling feature – this will allow you to input distinct values for all clients from one central, combined form. Finally, for more advanced use, we have the Round-robin data feature. It allows you to define arbitrary data that can be used by clients when filling out forms.

Automatic Form Filling

That’s an easy one! Simply focus a form element, and then press the Automatic form fill shortcut (by default, Ctrl-Shift-F, but you can change that in the Preferences). This will fill out all the fields of the form with random values – and of course, these values are synchronized across clients. In the Preferences, you can define how these values are generated for every form field type. We’ve included a set of rules that makes sense to use, such as E-mail, phone numbers, dates, colors – but of course, you can extend them any way you like.

Configuration options for Automatic form filling


Remote Form Filling

With Remote form filling, you can fill out forms on all clients from one single client. Simply navigate to a form field. Then, either triple-click it, or focus it and use the key shortcut (Ctrl-Space by default) to start remote form filling. A popup will open, providing you with a field for every connected client. The fields are labeled with the name of the device, and when you focus them, the respective client will visually identify. This feature is very useful whenever you want to quickly fill out distinct values across clients, e.g. for login purposes. In a way, it is the manual alternative to the QuickFill data, which also allows filling forms with client-distinct values, but in a more programmatic way.

Note: this feature is only available in Ghostlab 3.


The Remote form filling popup

Quickfill and Round-robin data

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.


A Quickfill function

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 Round-robin data (formerly called Quickfill data). This allows you to define various sets of data which you can then use on your clients via special shortcuts. 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 Round-robin data 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 Round-robin data to be available on the clients.

Round-robin data configuration

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 the shortcuts $0, $1, $2, etc. 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. Note: $0, $1, etc. had to be explicitly defined in Ghostlab 2. This is no longer the case – the shortcuts are now implicit. Of course it is still possible to access the quickFillData object from any of your custom Quickfills as you please.


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