TAG | API
20
Can I record arbitrary information with each transaction or step?
No comments · Posted by Patrick Lightbody in FAQ
For load tests, yes (we’re working to add support for this to monitoring). You can use BrowserMob API to add any name/value pair to your transactions or steps. Here’s a simple example:
var selenium = browserMob.openBrowser(); var tx = browserMob.beginTransaction(); var step = browserMob.beginStep("Home Page"); selenium.open("http://example.com"); // record how long it took for some text to appear var start = new Date().getTime(); selenium.waitForTextPresent("dynamic text"); var end = new Date().getTime(); // get a special cookie out and store it var cookie = selenium.getCookieByName("myCookie"); tx.put("cookie_value", cookie); // and store the "text" timing, associated with the step step.put("text_timing", end - start); browserMob.endStep(); browserMob.endTransaction();
The important things to notice here are that both beginTransaction() and beginStep() actually return objects that represent the transaction or step, respectively. You can then call put() on those objects to associate arbitrary data, such as custom timings or cookie values, with them.
Then when the transaction is stored in the load test database, you’ll be able to look them up in the name_value_pairs table. For more information on the test database schema, consult the documentation.
20
New Features: A new cloud location, Selenium 2 support, UI improvements, and new APIs
1 Comment · Posted by Patrick Lightbody in Announcements
We’re always working hard to improve our BrowserMob monitoring and load testing services. Over the last few weeks, we’ve pushed pushed out a bunch of improvements:
New Monitoring and Load Testing Location
Hot off the heels of Amazon’s announcement of a new US West Coast cloud data center, we are happy to report that you can now schedule load tests and monitoring jobs from this new location. Simply select the “San Jose, CA” location when scheduling tests.
Selenium 2.0 Support
In December, Selenium 2.0 alpha 1 was released. This release dramatically improves the realism and reliability of Selenium scripts. We’re proud to say that you can try out Selenium 2.0 support (but keep in mind it’s still in alpha) by simply changing your selenium script from this:
var selenium = browserMob.openBrowser();
To this:
var selenium = browserMob.openBrowser(true);
We will continue to keep BrowserMob up-to-date with all the latest happenings in the Selenium world, as well as donate our time and code back to the Selenium project. We also upgraded all the BrowserMob browsers to have the latest version of Firefox (3.5.7) and Flash.
Schedule Load Test UI Improvements
We’ve also made scheduling a load test a lot easier. We now give you a realtime estimate of what the test will cost you, changing dynamically based on your test configuration. We also display tooltips explaining things like “location”, “ramp”, and “constant”. Finally, we’re really excited to have rolled out a “Run ASAP” option that will kick off the test as quickly as it can, usually within 10 minutes.

New Script Editor
Our users love that they can write their scripts using JavaScript, so we decided to make working on that JavaScript code even easier. By utilizing the Bespin open source project from Mozilla, you now will see a rich text editor with code syntax highlighting. If for some reason you’re having trouble with it, you can always switch back to the plain text editor.

New Load Test Charts
We’ve always been proud of our realtime load test charts, but some users had recently complained that they were too heavy-weight and were slowing down their browser. Of course, this is a perfect example of why performance in the browser is starting to matter just as much as performance on the server.
Responding to this complaint, we rewrote the charts from scratch, moving from YUI Charts (Flash-based) to Flot (Canvas-based). We hope you like them!

New Scripting API Improvements
If you do advanced scripting, especially with virtual users, you’ll definitely want to take a look out the BrowserMob scripting API. We added a whole bunch of useful functions, including:
- setFollowRedirect(true) now logs all intermediate HTTP requests
- You can now automatically verify response codes
- If a 3xx response code is returned when you expected something else, the Location header is logged
- You can tie in “interceptors” for both HTTP requests and HTTP responses, allowing very advanced scripting techniques
API · Bespin · Flot · Release Notes · Selenium · Selenium 2 · YUI Charts
20
Bypassing analytics, advertisements, and other third parties in BrowserMob
No comments · Posted by Patrick Lightbody in Uncategorized
Often when it’s time to run a load test or turn on website monitoring, you don’t necessarily want the transaction hitting all your third party components on the page.
For example, you don’t want your analytics software to record the visits as real visitors, since that would skew your marketing metrics. Likewise, you don’t necessarily want advertisements served up, especially if the ad vendor uses “click-through rates” (CTR) to optimize ad prices and a load test would artificially drive down the CTR.
While there are vendor-specific actions you can take to deal with this problem (ie: we cover Google Analytics here), sometimes the easiest solution is to modify your script so that the request is never made in the first place.
You can do this for both Real Browser User (RBU) and Virtual User (VU) scripts using some new APIs that we recently rolled out. They allow you to whitelist or blacklist certain hosts from having actual HTTP requests sent to them.
For example, suppose you want to exclude all requests to www.google-analytics.com from your website monitoring or website load test. Your script would need to do something like this:
var selenium = browserMob.openBrowser(); var c = browserMob.getActiveHttpClient(); c.blacklistRequests("http://www\\.google-analytics\\.com/.*", 200); browserMob.beginTransaction(); browserMob.beginStep("Step 1"); // rest of test...
This would ensure that any HTTP request to Google Analytics would be bypassed immediately and a fake 200 response code would be returned instead.
Sometimes it’s easier to whitelist “good” hosts instead of blacklisting specific ones. This is often the case for advertising networks, which tend to host content from dozens of different domains.
var selenium = browserMob.openBrowser(); var c = browserMob.getActiveHttpClient(); c.whitelistRequests(["http://www\\.example\\.com/.*", "http://images\\.example.com\\.com/.*"], 200); browserMob.beginTransaction(); browserMob.beginStep("Step 1"); // rest of test...
In this example, we are allowing all requests to www.example.com and images.example.com to go through, but faking any other request with an immediate 200 response code.
These whitelist and blacklist APIs are just one example of the powerful scripting you can do using the BrowserMob API and scripting environment. We encourage you to review the entire API documentation from time to time, as well as contact us if you ever have questions about them.
