SUPPORT

Contact Support

OPEN A TICKET

Form Authentication API

This document contains form authentication helper methods.

For further information, see Configuring Form Authentication in Netsparker Standard.

Methods

click(el, delay opt)

This method simulates a click for the specified el.

Parameters

This table lists and explains the method's parameters.

Name

Type

Attributes

Description

el

string |

HTMLElement

This is the element to click.

delay

number

<optional>

This is the number of milliseconds (thousandths of a second) by which the click should be delayed. Note that all delays are timed from the beginning of the script execution and do not work in sequence if there are several function calls with delays.

Example


// Click element by id
netsparker.auth.click('LoginButton');
// Click element by id after 2 seconds
netsparker.auth.click('LoginButton', 2000);
// Click element by DOM element reference
netsparker.auth.click(document.getElementsByTagName('BUTTON')[0]);

clickByQuery(query, delay opt)

This method simulates a click for the element specified by the CSS query.

Parameters

This table lists and explains the method's parameters.

Name

Type

Attributes

Description

query

string

This is the CSS query that locates the element.

delay

number

<optional>

This is the number of milliseconds (thousandths of a second) by which the click should be delayed. Note that all delays are timed from the beginning of the script execution and do not work in sequence if there are several function calls with delays.

Example


// Click element by using a complex CSS query
netsparker.auth.clickByQuery('#loginForm > div:nth‐child(2) > button');
// Click element by id
netsparker.auth.clickByQuery('#LoginButton');
// Click element by id after 2 seconds netsparker.auth.clickByQuery('#LoginButton', 2000);

executeInFrame(frameEl, code, delayopt)

This method executes the supplied code in the specified frame element.

Parameters

This table lists and explains the method's parameters.

Name

Type

Attributes

Description

frameEl

string |

HTMLElement

This is the frame element id or DOM reference to[a] execute code.

code

string

This is the code to execute.

delay

number

 <optional>

This is the number of milliseconds (thousandths of a second) by which the code execution should be delayed. Note that all delays are timed from the beginning of the script execution and do not work in sequence if there are several function calls with delays.

Example


// Clicks an element inside a frame
var frame = document.getElementsByTagName('IFRAME')[1];
netsparker.auth.executeInFrame(frame, 'netsparker.auth.click("LoginButton");');

log(message)

This method logs a message.

Parameters

This table lists and explains the method's parameters.

Name

Type

Description

message

string

The message.

Example

// Log a simple message

netsparker.auth.log('Hello world!');

login(usernameopt, passwordopt, delayopt)

This method attempts to find a login form and completes the specified credentials.

Parameters

This table lists and explains the method's parameters.

Name

Type

Attributes

Description

username

string

<optional>

This is the username to complete.

password

string

<optional>

This is the password to complete.

delay

number

<optional>

This is the number of milliseconds (thousandths of a second) by which the login should be delayed. Note that all delays are timed from the beginning of the script execution and do not work in sequence if there are several function calls with delays.

Example


// Login using hard‐coded values
netsparker.auth.login('john.doe', 'p4ssw0rd');
// Login using hard‐coded values after 2 seconds
netsparker.auth.login('john.doe', 'p4ssw0rd', 2000);
// Login using implicit credentials (current persona)
netsparker.auth.login();
// Login using implicit credentials (current persona) after 2 seconds
netsparker.auth.login(2000);

setInputValue(el, value, delayopt)

This method sets the value of the specified el.

Parameters

This table lists and explains the method's parameters.

Name

Type

Attributes

Description

el

string |

HTMLElement

This is the element to click.

value

string

This is the value to set.

delay

number

<optional>

This is the number of milliseconds (thousandths of a second) by which this set value operation should be delayed. Note that all delays are timed from the beginning of the script execution and do not work in sequence if there are several function calls with delays.

Example


// Set value by id
netsparker.auth.setInputValue('Username', 'john.doe');
// Set value after 2 seconds
netsparker.auth.setInputValue('Username', 'john.doe', 2000);
// Set value by DOM element reference
netsparker.auth.setInputValue(document.forms[0].elements[0], 'john.doe');

setValueByQuery(query, value, delayopt)

This method finds an input element using the CSS query and sets its value.

Parameters

This table lists and explains the method's parameters.

Name

Type

Attributes

Description

query

string

This is the CSS query that locates the element.

value

string

This is the value to set.

delay

number

<optional>

This is the number of milliseconds (thousandths of a second) by which this set value operation should be delayed. Note that all delays are timed from the beginning of the script execution and do not work in sequence if there are several function calls with delays.

Example


// Query complex paths
netsparker.auth.setValueByQuery('#loginForm > div:nth‐child(2) > input', 'john.doe');
// Query by id
netsparker.auth.setValueByQuery('#Username', 'john.doe');
// Set value after 2 seconds
netsparker.auth.setValueByQuery('#Username', 'john.doe', 2000);

Netsparker

Highly accurate, fast & easy-to-use Web Application Security Scanner

GET A DEMO