---
title: Capture Network Traffic with Selenium | TestingBot Blog
description: |-
  Today we're examining the captureNetworkTraffic selenium command, a little known gem in Selenium's command list.

  Selenium offers a feature, captur...
source_url:
  html: https://testingbot.com/blog/2011/12/21/capture-network-traffic-with-selenium
  md: https://testingbot.com/blog/2011/12/21/capture-network-traffic-with-selenium.md
---

# Network Traffic inspection with Selenium

By [Jochen D.](https://testingbot.com/about/jochen-d)2011-12-21

 Share on Facebook 

 Share on Twitter 

 Post on Reddit 

 Share link 

Today we're examining the captureNetworkTraffic selenium command, a little known gem in Selenium's command list.

Selenium offers a feature, captureNetworkTraffic, which allows you to intercept the network traffic as seen by the browser running your test. The response includes headers, status codes, timings and AJAX requests. It's especially useful if you're debugging requests in your browser.

An example on how to use this in ruby:

```ruby
require "rubygems"
gem "selenium-client"
require "selenium/client"
gem 'test-unit'
require 'test/unit'

gem "testingbot"
require "testingbot"

class ExampleTest < TestingBot::TestCase
  attr_reader :browser

  def setup
    @browser = Selenium::Client::Driver.new \
        :host => "hub.testingbot.com",
        :port => 4444,
        :browser => "firefox",
        :version => "8",
        :platform => "WINDOWS",
        :url => "http://www.google.com",
        :timeout_in_second => 60

    browser.start_new_browser_session(:captureNetworkTraffic => true)
  end

  def teardown
    browser.close_current_browser_session
  end

  def test_command
    browser.open "/"
    p browser.browser_network_traffic
  end
end
```

This will open Google in Firefox 8 and return the network traffic. An example of a response would be:

```bash
"403 GET http://localhost:5555/favicon.ico1333 bytes 94ms 
(2011-12-21T15:53:06.352+0100 - 2011-12-21T15:53:06.446+0100
 Request Headers - Host => localhost:5555 - 
User-Agent => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0.1) Gecko/20100101 
Firefox/8.0.1 - Accept => image/png,image/*;q=0.8,*/*;q=0.5 - 
Accept-Language => en-us,en;q=0.5 - Accept-Encoding => gzip, deflate - Accept-Charset => ISO-8859-1,utf-8;q=0.7,*;q=0.7 - 
Proxy-Connection => keep-aliveResponse Headers - Date => Wed, 21 Dec 2011 14:53:06 GMT - 
Server => Jetty/5.1.x (Windows 7/6.1 x86 java/1.6.0_26 - Content-Type => text/html - 
Content-Length => 1333 - Via => 1.1 (jetty)
```

This command is available on our Grid and can be used to debug requests and calculate how long a request takes.

[← Previous post Record video of your Selenium Tests](https://testingbot.com/blog/2011/12/19/record-video-of-your-selenium-tests) [Next post → TestingBot updates](https://testingbot.com/blog/2011/12/23/testingbot-updates)

## Sidebar

### TestingBot Cloud Testing

Run automated, manual and visual tests on remote browsers and devices. Sign up for a free trial.

[Free Trial](https://testingbot.com/users/sign_up)

### Latest articles

[![Announcing AI Test Insights](https://testingbot.com/assets/blog/2026/ai-insights.jpg)](https://testingbot.com/blog/ai-test-insights)

#### Announcing AI Test Insights

Use AI Insights to quickly discover why an automated test...

[Read: Announcing AI Test Insights](https://testingbot.com/blog/ai-test-insights)

[![Selenium vs Playwright 2026](https://testingbot.com/assets/blog/2026/selenium-vs-playwright-2026.jpg)](https://testingbot.com/blog/selenium-vs-playwright)

#### Selenium vs Playwright 2026

Comparing Selenium vs Playwright - which is the best test...

[Read: Selenium vs Playwright 2026](https://testingbot.com/blog/selenium-vs-playwright)

[![Maestro Physical Device Testing](https://testingbot.com/assets/blog/2026/maestro-physical.jpg)](https://testingbot.com/blog/maestro-physical-device-testing)

#### Maestro Physical Device Testing

Maestro testing in parallel on physical Android and iOS d...

[Read: Maestro Physical Device Testing](https://testingbot.com/blog/maestro-physical-device-testing)

## Related Articles

[![Selenium vs Playwright 2026](https://testingbot.com/assets/blog/2026/selenium-vs-playwright-2026.jpg)](https://testingbot.com/blog/selenium-vs-playwright "Selenium vs Playwright 2026")

### [Selenium vs Playwright 2026](https://testingbot.com/blog/selenium-vs-playwright)

Comparing Selenium vs Playwright - which is the best test framework for your usecase?

[Read article →](https://testingbot.com/blog/selenium-vs-playwright)

[![Selenium 20th birthday](https://testingbot.com/assets/blog/2024/selenium20.webp)](https://testingbot.com/blog/selenium-20-years "Selenium 20th birthday")

### [Selenium 20th birthday](https://testingbot.com/blog/selenium-20-years)

Celebrate Selenium's 20th birthday. An overview of the years.

[Read article →](https://testingbot.com/blog/selenium-20-years)

[![Playwright Testing on TestingBot](https://testingbot.com/assets/blog/2023/playwright-testing.jpg)](https://testingbot.com/blog/playwright-testing-introduction "Playwright Testing on TestingBot")

### [Playwright Testing on TestingBot](https://testingbot.com/blog/playwright-testing-introduction)

Learn how Playwright can run your automated tests on a variety of browsers, local or remote browsers on TestingBot.

[Read article →](https://testingbot.com/blog/playwright-testing-introduction)

[![Selenium WebDriver BiDi](https://testingbot.com/assets/blog/2024/bidi.webp)](https://testingbot.com/blog/webdriver-bidi "Selenium WebDriver BiDi")

### [Selenium WebDriver BiDi](https://testingbot.com/blog/webdriver-bidi)

WebDriver BiDi support is now available on TestingBot. Learn how to use this exciting new improvement with your Selenium tests.

[Read article →](https://testingbot.com/blog/webdriver-bidi)

## More by Jochen D.

[![Announcing AI Test Insights](https://testingbot.com/assets/blog/2026/ai-insights.jpg)](https://testingbot.com/blog/ai-test-insights "Announcing AI Test Insights")
### [Announcing AI Test Insights](https://testingbot.com/blog/ai-test-insights)

Use AI Insights to quickly discover why an automated test failed.

[![Maestro Physical Device Testing](https://testingbot.com/assets/blog/2026/maestro-physical.jpg)](https://testingbot.com/blog/maestro-physical-device-testing "Maestro Physical Device Testing")
### [Maestro Physical Device Testing](https://testingbot.com/blog/maestro-physical-device-testing)

Maestro testing in parallel on physical Android and iOS devices.

[![tvOS Physical Device Testing](https://testingbot.com/assets/blog/2025/appletv.jpg)](https://testingbot.com/blog/tvos-automated-testing "tvOS Physical Device Testing")
### [tvOS Physical Device Testing](https://testingbot.com/blog/tvos-automated-testing)

Run automated tvOS tests on physical AppleTV devices.

[See all posts by Jochen D. →](https://testingbot.com/about/jochen-d)

## Ready to start testing?
[Start a free trial](https://testingbot.com/users/sign_up)
