Performance Testing Documentation

With this call, you can fetch various performance metrics from the browser, during your test.

With this functionality, you can create tests where you monitor specific pageload time, or any other metric.
If the metric is below a specific threshold that you define, you can make the test fail.

((JavascriptExecutor) driver).executeScript("tb:performance");


pageSize (bytes) The size (in bytes) of the page (HTML source).
nrRequests How many requests the page made (AJAX/images/...)
load (ms) The pageload time of the webpage.

​​​The time it takes for a page to download and diplsay the entire web page.

domContentLoaded (ms) The domContentLoaded duration of the page.

The DOMContentLoaded event fires when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.

DOMContentLoaded Info
firstMeaningfulPaint (ms)

Indicates how fast your page displays its primary content.

firstMeaningfulPaint Info
firstPaint (ms) First Paint is triggered when a render (any render) is detected in the browser.
firstContentfulPaint (ms)

First Contentful Paint measures the time from navigation to the time when the browser renders the first bit of content from the DOM.

firstContentfulPaint Info

Example Response:

  "pageSize" => 396800,
  "nrRequests" => 20,
  "load" => 1378,
  "domContentLoaded" => 585,
  "firstMeaningfulPaint" => 0,
  "firstPaint" => 348,
  "firstContentfulPaint" => 348

Sample UseCase:

This example demonstrates a test that visits a page, checks the performance and fails the test if the performance is not sufficient.

require "rubygems"
require "selenium-webdriver"
require "selenium/client"

caps = {
  :browserName => "chrome",
  :version => "latest",
  :platform => "WIN10",
  :debugging => true

urlhub = "https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub"
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 120

@webdriver = Selenium::WebDriver.for :remote, :url => urlhub, :desired_capabilities => caps, :http_client => client

@webdriver.navigate.to "https://testingbot.com/"
performance = @webdriver.execute_script("tb:performance")
assert performance["load"] < 900