DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > Modifying Network Requests With Iridium

Modifying Network Requests With Iridium

With its built in proxy, the Iridium testing tool allows your to modify network requests as part of your integration tests

Matthew Casperson user avatar by
Matthew Casperson
·
Jul. 20, 16 · Web Dev Zone · Tutorial
Like (2)
Save
Tweet
3.43K Views

Join the DZone community and get the full member experience.

Join For Free

If you are just getting started with Iridium, please read the article An Introduction to Iridium, an Open Source Selenium and Cucumber Testing Tool.

A common requirement when writing browser tests is the ability to modify network requests. There are a number of reasons why you may want to do this including:

  • Simulating failures of backend systems
  • Blocking access to analytics to prevent your stats from being influenced by test runs
  • Blocking access to static resources like images to speed up tests
  • Preventing timeouts for resources that a CI system can’t access

Iridium embeds the BrowserMob proxy and exposes steps that can be used to support the above situations. To demonstrate this, let’s look at how you would modify the test of the DZone website in order to speed it up via the removal of image loading.

To run this example, right click, download and run this Web Start file. If you have not already done so, ensure that you have trusted the location where the Iridium JAR file is downloaded from using the instructions in the installation chapter of the getting started guide.

The only change to the test scripts shown in previous examples is the addition of a step that intercepts requests matching a certain regular expression (anything with the string “thumbnail” in our case) and immediately returns a 500 response code.

# Open up the web page
Scenario: Launch App
  And I set the default wait time between steps to "2"
  # Speed up tests by blocking thumbnails
  And I block access to the URL regex ".*?thumbnail.*" with response "500"
  And I open the application
  And I maximise the window

There is no additional configuration required for this step to work, as BrowserMob is enabled and configured by default.

Running the test confirms that the page being loaded indeed has no thumbnail images present. This significantly speeds up the execution of the test, as it removes a large percentage of the bandwidth required to load a page.

Screen Shot 2016-07-17 at 10.13.19 AM.png

For more information on the Iridium testing tool, check out the documentation and the GitHub project.

Requests Network

Published at DZone with permission of Matthew Casperson, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Top 5 Datadog Integrations To Improve the Efficiency of Tech Teams
  • Want To Be a Terrible Engineering Manager? Be a Sh*t Shield
  • Combining gRPC With Guice
  • You Should Never Use Flags For Language Choice

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo