We at www.leankoala.com do a lot of tests (65.000.000 since the beginning of the year). Most of them involve the Selenium Webdriver.

On the one hand, we love that tool. It is the de-facto standard for browser testing and works with almost every browser and every programming language. On the other hand, it is sometimes unstable, some errors are very hard to debug and with only Webdriver, a lot of things are not solvable.

One thing we often want to do in our tests is to inject javascript snippets at the beginning of the HTML file. This is not possible as Selenium gives the control to the browser. Only after the rendering is done the user can interact with the page. The time when you are able to inject js code it can be too late. When we started working with Selenium we took that as God-given.

After understanding how the Webdriver works we came to a solution to handle such problems. Selenium is not able to do that. That’s right. But Selenium is able to inject google chrome extension before running. So you are able to write the code you want to be called before inside such an extension and it will run up front.

As www.leankoala.com is a PHP company we are using the Facebook library for Webdriver that makes the injecting very easy.


When you want to interact with the extension it can be done by javascript. Another easy approach is to collect the needed data within chrome and then write that information into a cookie. That can be read by Selenium and PHP. But you can also use the local storage.

This way we solved most of our requirements at www.leankoala.com.