The BrowserMob Blog | All about browsers, performance testing, and load testing

Recording Test Scripts

If you’ve recorded scripts for load tests before, you know how painful and difficult this process can be. If this is your first load test, you might be anxious about what’s involved. The good news is: recording tests with BrowserMob is as easy as can be – far easier than any other load testing tool.

Traditional Scripting is Painful

With just about every other open source and commercial load testing product available, scripting becomes difficult due to the fact the recorders simply record HTTP traffic, leaving the exercise of parameterizing the traffic, compensating for dynamic variables and AJAX, and managing state/session cookies by hand. This process is painful.

BrowserMob Scripting is Easy

Fortunately, BrowserMob makes scripting painless. Instead of recording HTTP traffic, we only need to record user interactions in the browser. Because we use real browsers, we can play back those user interactions for every virtual user, allowing the real browser to do all the heavy lifting, such as handling AJAX, cookies, and complex pages. This cuts script creation time down from days or weeks to minutes.

Getting Started

BrowserMob leverages existing open source technologies for script recording, in this case Selenium IDE. By using open source, we keep our costs low, which means your prices are lower. Selenium is also one of the most popular open source functional testing tools around, so there is a good chance you or your coworkers already are familiar with it.

To get started, you’ll need to install Selenium IDE in to your Firefox browser as a plugin. First, go to theĀ download page for Selenium IDE in your Firefox browser. If you aren’t currently using Firefox, download and install Firefox and paste this link in to your browser:

http://seleniumhq.org/download

Next, you’ll need to click on the link to download and install the latest version of the plugin (version 1.0 beta 2 at the time of this writing):

Firefox will warn you about the plugin. This happens for any plugin not created or authorized by Mozilla and it is safe to continue. Click “Allow” to continue installing the plugin.

Again Firefox will give another warning. Click “Install Now” to continue the installation. If you’re concerned about malicious software, we encourage you to search online for Selenium and visit the Selenium IDE home page so that you can feel more comfortable about the software. You are also welcome to contact us if you have any security concerns.

Once the plugin has finished downloading, you’ll need to restart Firefox before the installation is complete. Click the “Restart Firefox” button to finish the installation.

That’s it! Selenium IDE is now installed.

Recording a Test

Now that you have the software, let’s record a simply script. For this example, we’ll record a script that searches Google for the phrase “introduction to selenium ide“, and then clicks on the link to a blog that discusses how to use Selenium IDE. Finally, the script will verify some bit of text on the page to confirm we’re in the right place.

Note: we recommend reading this blog and the hundreds of others out there to learn how to do more advanced Selenium scripting.

To start Selenium IDE, first go to starting point of your script, in this case http://google.com. Then select Tools -> Selenium IDE from the menu.

You’ll then see the Selenium IDE recorder pop up in a new window. It should look like this:

Please note: the record button (the red circle) is depressed when you start Selenium IDE. This means it’s already in record mode. You should not click it right now, since this will turn off record mode.

Now that Selenium IDE is on and ready to record, go back to the browser window where you had Google open. Just do a search like you normally would:

  1. Type in “introduction to Selenium IDE” in to the search box.
  2. Click on the “Google Search” button.
  3. Click on the “Introduction to Selenium IDE” link (usually the first or second link).
  4. Highlight the text on the page that says “get you up and running in no time at all”.
  5. Right click on the highlighted text. You’ll see menu items that are new. These are only visible when Selenium IDE is recording a script. Select the verifyTextPresent command, as shown here:

That’s it! You’ve recorded your first script. Now go back to the Selenium IDE window and you’ll see that it’s changed a bit. It has recorded the commands required to play back the interactions you just did in your browser.

Important: always play back your script before uploading it to BrowserMob. This will confirm that it recorded correctly and thus will run correctly during the load test. We recommend you reset your cookies as well to ensure that your Firefox browser is in the same state as the BrowserMob browsers. You’ll know the test played back correctly when you all the rows are colored green after playback.

Once you’ve verified playback, you’ll need to save the script to your hard drive before you can upload it to BrowserMob. Be careful: Selenium IDE lets you save test suites and test cases. You want to save the test case.

Once the file has been saved, you can use it to upload to BrowserMob when scheduling on-demand load tests. This is covered in the next section.

Note: there are many commands for Selenium IDE, as well as techniques for load testing, error checking, and content validation. We will not cover advanced topics in this document, but do look through our blog and the rest of the help documentation as more advanced topics are covered there.

[Post to Twitter] Tweet This Post 

No comments yet.

Leave a Reply

Theme Design by devolux.nh2.me

Tweet This Post links powered by Tweet This v1.3.9, a WordPress plugin for Twitter.