Skip to content
Parashuram N edited this page Feb 27, 2017 · 9 revisions

Frequently asked questions

How do I run tests like clicking buttons instead of simply scrolling the page?

Use the browser-perf node module, and define custom actions.

How do I scroll a custom element ?

You can use something like the following for scrolling a custom element. Define this in the actions key.

    actions : [browserperf.actions.scroll({
        scrollElement: 'document.getElementsByClassName("myclass")[0]'
    })]

A full example can be found as a gist.

How can I test a page that requires login?

You can use the preScript option to log in and ensure that a cookie is set. When running the test, the cookie will still be used and you will be able to test the page as a logged in user. For example, with the node API, pass the following to the preScript option.

... // other config options for browser-perf
preScript: browserPerf.actions.login({
  username: {
    field: 'CSS_for_Username_textbox_in_form',
    value: 'Username_to_be_typed'
  },
  password: {
   field: 'CSS_for_Password_textbox_in_form',
   value: 'password_to_be_typed'
  },
  submit:{
    field: 'Submit_Button_CSS_Selector_In_Form'
  }
})

Any recommendations on how to store and view this data later?

Perfjankie is a module built on top of browser-perf that saves the results and HTML to display graphs in a CouchDB database. We use it for generating graphs like this.

What if I run into errors/cannot run the tests?

The steps to debug the issue would be

  1. Is selenium running?
  2. Can you open a browser using selenium? You can use the wd module directly to see if selenium works.
  3. Run browser-perf with a debug flag and verbose flags. This will leave the browser windows open after the tests and give you extensive logging.
  4. Contact us if you still encounter issues.

How to enable debug logs

Browser-perf uses the debug module for debug logging. To get a stack trace, set the environment variable DEBUG to * using export DEBUG=* (Mac/Linux) or set DEBUG=* (Windows). If you then run browser-perf, you would get logs that would be helpful in debugging the actual issue.

How to get consistent results ?

Here are some tips to ensure that the tests you run result in consistent results

  • Ensure that only one user scenario is run. For example, a simple page scroll will result in more consistent results than a test that runs scrolls on multiple pages, loading one page after another.
  • Ensure that you disable all metrics that you may not be interested in. For example, when using the Node API to record only rendering metrics and ignore network metrics, use metrics: ['ChromeTracingMetrics', 'TimelineMetrics'] in the options object of browser-perf. This basically prevents any network related scripts from running and skewing the results.
  • Note that browsers also have a lot of optimizations in the background and this could also result in a slight skew in the metrics. It is recommended to run the test multiple times and compare the results with previous runs.