Skip to content
August 14, 2013 / selenium34

PhantomJS + Plugins + AWS + BrowserMob Proxy

What an adventure to get this working. Long story short, it was RPM hell on a standard aws instance, get the Ubuntu instance from the AWS marketplace.

The other week I needed to do some work testing flash events which are triggered during video playback. Sauce Labs is nice enough to allow us to use browsermob proxy now, but it made little sense to pay them to do this testing. They were basically going to record a video of us watching a video… That’s a good use of those minutes I tell you…

I had a machine in aws which was being utilized as a BrowserMob Proxy instance and a Sauce Connect instance. I decided I would attempt to re-purpose that machine to be a PhantomJS Grid instance which I could connect to. That was easy enough. Our base tests which relied upon the proxy worked just fine. However, the ones which required flash were not working. Makes sense, since flash support was dropped in 1.5. Then I stumbled across this post. I was excited… Then I tried to get it running.

Since this was a default aws instance, I tried the RPM which was listed. It refused to work (I tested with the small script on the blog post). I then tried to use the pre-compiled binary. Enter dependency hell. Things were not going smoothly, I wasn’t having much luck finding all of the dependencies, and they didn’t seem to live in the epel repository, which you can easily enable on a default aws instance. I wasted a day and a half trying to get everything going. I’ll be the first to admit, my Linux chops are a bit rusty, but finding what repo a dependency lives in is a chore. Adding that repo is even worse (my google fu was weak on this, and I wasn’t sure where to find a list of repo rpms or .repo files for download).

I decided to start fresh. I found this image for Ubuntu 12.04 in the AWS marketplace. I got the instance going. Added the dependencies (much easier this time), and then added flash. To get the flash installer, I simply needed to add multiverse to the repo.

After starting up Xvfb and exporting the DISPLAY environment variable, I reran the snap test listed on Ryan’s blog, and lo and behold I had an image of the flash video working. Now I needed it to work as a RemoteWebDriver instance…

Sure enough it was as simple as I hoped it would be. I got my proxy up and running:

browsermob-proxy -port 9090 &
curl -X POST -d 'port=9091' http://localhost:9090/proxy

Then I started the grid:

java -jar selenium-server-standalone-2.35.0.jar -role hub -port 9001 &

Then I started up phantomjs:

phantomjs --webdriver=8080 --webdriver-selenium-grid-hub= --proxy= --load-plugins=yes

Then I used the following as my driver instance:

new RemoteWebDriver(new URL(""), DesiredCapabilities.phantomjs());

To test that flash was working in the grid instance, I wrote a bit of Swing code to grab the screenshot of the remote browser, and display it. Now I can even see what the headless browser is doing while testing.

I can now make calls to the Restful API of browsermob and retrieve the har files where I can verify if my events are taking place as they should.



Leave a Comment
  1. selenium34 / Aug 28 2013 3:24 pm

    This looks like it could be a solid follow on to this article:

  2. Our Webpage / Oct 17 2014 5:21 am

    Wow, awesome weblog structure! How long have you been running a blog for?
    you make blogging glance easy. Thhe total look of your
    web sit is great, let alone the content!


  1. A Smattering of Selenium #157 | Official Selenium Blog
  2. Why are we using BrowserMob Proxy? | Ramblings on Selenium
  3. A Smattering of Selenium #157 | Internet Deal
  4. A Smattering of Selenium #157 | SQA Tutorial
  5. Options for Validating HTTP Codes in Selenium – scribdbook

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: