Execute Script - Web Performance
Menu

Execute Script

Execute Script gives the tester access to the Selenium/WebDriver Java APIs in a JavaScript environment.

Creating the script

When adding or editing a step, change the action type to Execute Script. This action has a single datasource, which contains the script. Press the datasource edit button to edit the script.

The script will be pre-populated with a simple example and a little documentation to help you get started.

Examples

We find real examples to be more helpful than pages of verbiage, so we’ll maintain a list of scripts that we’ve found useful for your reference:

Java/JavaScript

JavaScript is a great choice for a scripting language – as it is the de-facto standard for web scripting and most web developers and testers are familiar with it. However, because Load Tester is a Java application and uses the Java APIs for Selenium/WebDriver, it exposes the Java APIs through a translation layer into JavaScript. For the most part, this translation is seamless. If you are familiar with the Java WebDriver APIs, you will find working in JavaScript is fairly easy. We hope that if you are familiar with one of the JavaScript Selenium/WebDriver APIs, you will also find the transition painless. In either case, we’d love to hear your feedback, so please relay your experiences to our support engineers.

Caution

The scripting environment gives the tester a lot of power. Including the ability to hang the virtual user in a loop, consume all the available memory, and maybe even crash Load Tester. Please be careful!

DataSets

Load Tester needs to know what DataSets are used by the testcase – which means that it needs to know what DataSets are used by each step. This is needed to distribute the right DataSets to the load engines. Under normal use, this is completely seamless. But because a script could reference a DataSet in a way that Load Tester cannot detect, the required DataSets must be explicitly declared.

To do this, implement the getDatasetsRequired() method. If no DataSets are used by the script, the getDatasetsRequired() function can be omitted or return null. Otherwise the function should return the name of the required DataSet (or an array of names) used by the script. This will ensure that the correct DataSets are sent to the load engines, but it does NOT support automatic renaming of DataSets. The scripts must be updated manually.

Copyright © 2024 Web Performance, Inc.

A Durham web design company

×

(1) 919-845-7601 9AM-5PM EST

Just complete this form and we will get back to you as soon as possible with a quote. Please note: Technical support questions should be posted to our online support system.

About You
How Many Concurrent Users