Name: webpagetest-ruby
Owner: Vox Media
Description: null
Created: 2015-10-27 20:09:05.0
Updated: 2017-08-29 15:01:50.0
Pushed: 2015-11-05 20:39:47.0
Homepage: null
Size: 112
Language: Ruby
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This gem is a Ruby wrapper for the main features of Webpagetest REST API. Features included so far:
This gem is inspired by Susuwatari gem, so several ideas were taken from there (it's like a rewrite with some modifications). There were two main reasons to create a new Webpagetest
gem:
Client
class is focused on test runs, but no general-purpose wrapper has been built so far (for example, locations were missing).Add this line to your application's Gemfile:
gem 'webpagetest'
And then execute:
$ bundle
Or install it yourself as:
$ gem install webpagetest
All you require to use the gem is a Webpagetest API key in order to run tests. You can ask your own by emailing Patrick Meenan, like he explains in Webpagetest docs.
Basically, you need to instantiate an object of Webpagetest
class, and then use it to interact with the API.
ire 'webpagetest'
= Webpagetest.new(k: your_api_key)
When running a test, a Response
object is returned, with the following available methods:
test_id
: the id
assigned to the submitted teststatus
: the status of the test (nil
at the beginning)result
: the result object (nil
at the beginning)raw
: the raw response of the requestget_status
: makes a test status request, and fetches the result when status is :completed
onse = wpt.run_test do |params|
params.url = 'http://webpagetest.org'
st is running, so status must be requested
onse.get_status # => :running
en test is completed, status will be updated
onse.get_status # => :completed
ly after knowing that test is completed, the result is set
onse.result.keys
[ 0] "id",
[ 1] "url",
[ 2] "summary",
[ 3] "testUrl",
[ 4] "location",
[ 5] "from",
[ 6] "connectivity",
[ 7] "bwDown",
[ 8] "bwUp",
[ 9] "latency",
[10] "plr",
[11] "completed",
[12] "testerDNS",
[13] "runs",
[14] "fvonly",
[15] "successfulFVRuns",
[16] "successfulRVRuns",
[17] "average",
[18] "standardDeviation",
[19] "median",
[20] "status_code",
[21] "status_text"
onse.result.runs[1].firstView.loadTime # => 2051
In order to get a result based on a test id
, the same procedure as above must be done.
= wpt.test_result("some_test_id") # test is a Response object
onse.test_id # => "131007_FC_WHR"
st could be running or completed
onse.get_status # => :completed
onse.result.average.firstView.domElements # => 714
tions = wpt.locations
tions.keys
[ 0] "Dulles_IE6",
[ 1] "Dulles_IE10",
[ 2] "Dulles:Chrome",
[ 3] "Dulles:Canary",
[ 4] "Dulles:Firefox",
[ 5] "Dulles_iOS",
[ 6] "Dulles_Android",
[ 7] "Dulles_Thinkpad:Chrome",
[ 8] "Dulles_Thinkpad:Canary",
[ 9] "Asheville_IE",
[ 10] "Miami_IE8",
[ 11] "Miami:Chrome",
[ 12] "Miami:Firefox",
...
This gem is just a starting point wrapper, so much work can be done from here.
Any contribution is appreciated. Just fork this repository and submit the appropriate pull request if you want to add features to this gem.