Project

speedos

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Incorporates BrowserMob and Capybara(selenium) to run front-end tests and capture performance information
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

= 2.14.1

Runtime

= 2.1.0
= 1.1.2
= 1.2.8
= 3.1.4
= 10.1.0
 Project Readme

Speedos

What is Speedos?

Speedos incorporates BrowserMob Proxy along with Capybara, recording the web traffic and time taken to load all elements on each of the pages within a user journey. The aim is to identify any performance related issues, such as specific items that take a long time to load on page.

Installation

Put speedos on your Gemfile

gem 'speedos'

# MUST ADD: 'selenium-webdriver', '2.35.1'
gem 'selenium-webdriver', '2.35.1'

# OPTIONAL (if you want to use a properly working harviewer):
gem 'har', git: 'https://github.com/PeterWuMC/har.git'

Or, install it via rubygem

$ gem install speedos

The easiest and quickest way to get you started is to run the init script

$ speedos init

and it will generate following file structure for you:

├── .irbrc
├── Rakefile
├── config
│   ├── initializer.rb
│   └── mongoid.yml
├── helpers
├── log
└── scripts

Configuration

Mongoid

It is essential to let speedos know the location of your mongoid.yml by...

Speedos::Configuration.load_mongoid_config('/location/to/my/mongoid.yml')

Refer to mongoid documentation for the correct format of mongoid.yml http://mongoid.org/en/mongoid/docs/installation.html

Logger

By default, speedos will output all the logging using STDOUT, you can override this method by either

# pass in a Logger Object
Speedos::Log.logger = Logger.new(…)

or

# the location where you want the log to be saved
Speedos::Log.logger = "/location/to/desire/log/location"

Create your own script

you should put all your script under /scripts

require 'speedos'

Speedos::Performance.test do |page|
  page.is 'simplybusiness-main-page' do
    # page.driver is a capybara session instance
    page.driver.visit   'https://www.simplybusiness.co.uk/'
    page.driver.fill_in 'ctaText', with: "IT contractor"
  end

  page.is 'business-insurance-page' do
    page.driver.find_button('ctaBtn').click
  end
end

To execute the scripts

If you use init to generate your structure, you should get Rakefile created. And it will create rake task for all the scripts you have created in /scripts

└── scripts
    ├── earth
    │   └── grass.rb
    ├── human.rb
    └── sky
        ├── cloud.rb
        └── rain.rb

For example, if you have above scripts structure, then you should get the following rake tasks created

$ rake -T

rake earth:grass  # run the script located in /Users/pwu/test/scripts/earth/grass.rb
rake human        # run the script located in /Users/pwu/test/scripts/human.rb
rake sky:cloud    # run the script located in /Users/pwu/test/scripts/sky/cloud.rb
rake sky:rain     # run the script located in /Users/pwu/test/scripts/sky/rain.rb

Report

You can access the performance data via Speedos::Record object

$ irb

> Speedos::Record.first.pages
#=> [Entries: ["simplybusiness-main-page"], Entries: ["google-result-page"]]

> Speedos::Record.first.pages.first
#=> Entries: ["simplybusiness-main-page"]

> Speedos::Record.first.pages.first.total_load_time
#=> 3828.0
# which is the total loading time for the page in milliseconds