Converting Selenium Scripts to Acunetix LSR Files

Selenium is a tool that allows you to automate browser actions. It is often used by QA engineers to automatically and efficiently test the functionality of web applications. You can create Selenium scripts that examine the specific functionality of a web application, ensuring that it produces the expected results.

One of the types of pages that you need to test in the case of most web applications are login pages. Selenium scripts are often used to ensure that changes in the web application do not break the login functionality. These Selenium scripts can be converted and used by Acunetix to log in to the site as part of the security scan.

The pre-recorded login sequence setting in Acunetix supports Selenium Login Scripts. The login actions are taken from the Selenium script and the auto-login feature is used to identify any restricted links, such as Logout links, and the session detection pattern. This article shows you how to convert a selenium script into an Acunetix LSR file via the Acunetix UI and via the Command Line.

Prepare the Selenium Login Script

  1. Confirm that the Selenium Login Script is working as expected. You can do this using the Play button to confirm that all the steps are executed correctly. Use the Timer drop-down to configure the playback speed.

Selenium Login Script

  1. Save the Selenium Login Script to a file.

How to convert a Selenium Script to an Acunetix LSR File from the Acunetix UI

  1. Navigate to the Target Settings page for the target you wish to add the Selenium script.
  2. Enable the Site Login toggle, then select Use pre-recorded login sequence.
  3. Click Import From Selenium and choose the Selenium script saved earlier.

  1. The Login Sequence Recorder will open the Selenium script, convert it to a login sequence, and run through the actions identified. In addition, it will automatically identify any logout links and the session detection pattern. Click OK on the pop-up stating that the script was imported successfully.

Confirm login sequence import

  1. Confirm the restricted links and the identified session detection pattern. Click Save when done.
  2. You will be taken back to the Target Settings page and the new LSR file will be attached to the target. Click Save to confirm the changes to the target settings.

How to convert a Selenium Script to an Acunetix LSR Files from the Command Line

This method can be useful if you need to convert many Selenium scripts into Acunetix LSR files. You can then use the Acunetix API to auto-attach the scripts to targets.

  1. Open Command Prompt.
  2. Change the directory to C:\Program Files (x86)\Acunetix\core\.
  3. Execute the following command:

node lsr generate --sourcetype selenium

  --source your_source_selenium_file

  --destination the_destination_LSR_file 

For example:

node lsr generate --sourcetype selenium

  --source "C:\users\admin\Downloads\testphp_login.side"

  --destination "C:\users\admin\Downloads\testphp_login.lsr"

  1. The Login Sequence Recorder will load the Selenium file and create login actions. It will then proceed with verifying login actions as well as identifying restricted links and a valid session detection pattern. This might take some time to complete. Progress will be visible in the command prompt window.

Selenium Conversion Command Prompt

  1. You can now upload the resulting .lsr files to the Target Settings > Site Login section for different targets or use the Acunetix API to attach the LSR to a specific target.

 

« Back to the Acunetix Support Page