With the release of TestingBot's Performance Testing, you can now retrieve various performance metrics from Chrome during your Automated Tests.
We fetch these various metrics from the Chrome browser via Chrome's Devtools Protocol.
TestingBot has added custom WebDriver commands which you can use to fetch metrics from the Chrome browser during your test, including:
- Pageload Time
- Number of HTTP(s) requests
- domContentLoaded
- firstPaint metrics
With this new feature, you can for example add checks in your Automated tests to verify if the Pageload Time is below a specific threshold.
If the Pageload Time is too high, the test will fail, alerting you that a performance regression occurred.
Please see our Frontend Performance Testing Documentation for more details on how to use this feature.
Sample Code:
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 # if the pageload time is below 0.9 seconds, fail the test.
@webdriver.quit