| Andrew Cooke | Contents | Latest | RSS | Twitter | Previous | Next


Welcome to my blog, which was once a mailing list of the same name and is still generated by mail. Please reply via the "comment" links.

Always interested in offers/projects/new ideas. Eclectic experience in fields like: numerical computing; Python web; Java enterprise; functional languages; GPGPU; SQL databases; etc. Based in Santiago, Chile; telecommute worldwide. CV; email.

Personal Projects

Lepl parser for Python.

Colorless Green.

Photography around Santiago.

SVG experiment.

Professional Portfolio

Calibration of seismometers.

Data access via web services.

Cache rewrite.

Extending OpenSSH.

C-ORM: docs, API.

Last 100 entries

Re: Quick message - This link is broken; Adding Reverb To The Echo Chamber; Sox Audio Tools; Would This Have Been OK?; Honesty only important economically before institutions develop; Stegangraphy via PS4; OpenCL Mess; More Book Recommendations; Good Explanation of Difference Between Majority + Minority; Musical Chairs - Who's The Privileged White Guy; I can see straight men watching this conversation and laffing; When it's Actually a Source of Indignation and Disgust; Meta Thread Defending POC Causes POC To Close Account; Indigenous People Of Chile; Curry Recipe; Interesting Link On Marginality; A Nuclear Launch Ordered, 1962; More Book Recs (Better Person); It's Nuanced, And I Tried, So Back Off; Marx; The Negative Of Positive; Jenny Holzer Rocks; Huge Article on Cultural Evolution and More; "Ignoring language theory"; Negative Finger Counting; Week 12; Communication Via Telecomm Bids; Finding Suspects Via Relatives' DNA From Non-Crime Databases; Statistics and Information Theory; Ice OK in USA; On The Other Hand; (Current Understanding Of) Chilean Taxes / Contributions; M John Harrison; Playing Games on a Cloud GPU; China Gamifies Real Life; Can't Help Thinking It's Thoughtcrime; Mefi Quotes; Spray Painting Bike Frame; Weeks 10 + 11; Change: No Longer Possible To Merge Metadata; Books on Old Age; Health Tree Maps; MRA - Men's Rights Activists; Writing Good C++14; Risk Assessment - Fukushima; The Future of Advertising and Surveillance; Travelling With Betaferon; I think I know what I dislike so much about Metafilter; Weeks 8 + 9; More; Pastamore - Bad Italian in Vitacura; History Books; Iraq + The (UK) Governing Elite; Answering Some Hard Questions; Pinochet: The Dictator's Shadow; An Outsider's Guide To Julia Packages; Nobody gives a shit; Lepton Decay Irregularity; An Easier Way; Julia's BinDeps (aka How To Install Cairo); Good Example Of Good Police Work (And Anonymity Being Hard); Best Santiago Burgers; Also; Michael Emmerich (Vibrator Translator) Interview (Japanese Books); Clarice Lispector (Brazillian Writer); Books On Evolution; Looks like Ara (Modular Phone) is dead; Index - Translations From Chile; More Emotion in Chilean Wines; Week 7; Aeon Magazine (Science-ish); QM, Deutsch, Constructor Theory; Interesting Talk Transcripts; Interesting Suggestion Of Election Fraud; "Hard" Books; Articles or Papers on depolarizing the US; Textbook for "QM as complex probabilities"; SFO Get Libor Trader (14 years); Why Are There Still So Many Jobs?; Navier Stokes Incomplete; More on Benford; FBI Claimed Vandalism; Architectural Tessellation; Also: Go, Blake's 7; Delusions of Gender (book); Crypto AG DID work with NSA / GCHQ; UNUMS (Universal Number Format); MOOCs (Massive Open Online Courses); Interesting Looking Game; Euler's Theorem for Polynomials; Weeks 3-6; Reddit Comment; Differential Cryptanalysis For Dummies; Japanese Graphic Design; Books To Be Re-Read; And Today I Learned Bugs Need Clear Examples; Factoring a 67 bit prime in your head; Islamic Geometric Art; Useful Julia Backtraces from Tasks; Nothing, however, is lost with less discomfort than that which, when lost, cannot be missed; Article on Didion

© 2006-2015 Andrew Cooke (site) / post authors (content).

Selenium Tests of Multiple Browser and OS Combinations

From: andrew cooke <andrew@...>

Date: Wed, 11 Aug 2010 16:07:57 -0400

This is a follow-up to my earlier post on Selenium at
http://www.acooke.org/cute/SeleniumWe0.html - there I gave a summary of
Selenium and the basic tools needed to run simple, single tests.

However, what is interesting me at the moment (because we need it at work) is
how to run the same test in several browsers, on different operating systems.
This requires two things:

1 - A way to distribute jobs across machines
2 - A way to make tests general (the tests in the first article specified
    the target browser).

Selenium provides these things via something called "Selenium Grid", although
much of the documentation for that focuses on running tests in parallel (for
speed) rather than on exploiting different environments.

A warning: the Selenium Grid documentation sucks.  I have spent a frustrating
couple of days getting this working.  Even the demo they provide to test the
system doesn't work.  And the system itself seems a bit limited and
unreliable.  But, unfortunately, I don't see anything better.

OK, so what is Selenium Grid?  It's three things:

A - A central hub that manages a collection of servers
B - A collection of servers (possibly on remote machines)
C - Library support for writing tests

(A+B) address (1) above and (C) addresses (2).  This is all packaged in a Java
deploy and run using ant-based scripts.

First, I want to describe how the distribution of tasks works, because I found
this far from intuitive.  It's important to understand that all the servers
(called "remote controls") are equivalent and dumb.  They don't "know" that
they are running on Windows, or can access the Opera browser, for example.
The only way that such information is made available to the system is through
the *environment*.

When you start a server you specify its environment.  This is a string, and
the standard form is something like "IE on Windows" or "Firefox on Linux".
That information is passed by the server to the central hub which uses that
(and only that) to route tests.

The hub is also contacted by the test.  The test requests a particular
environment (I'll address 2/C below) and the hub then routes the test to the
corresponding server.

At this point it's probably worth describing exactly how these things run.
This is how I start the hub and a local server on Linux (first script uses
konsole as they log to stdout - although on Windows you don't see anything,
and I don't understand why):

  > cat startup-selenium.sh
  konsole --hold -e startup-hub.sh &
  sleep 5
  konsole --hold -e startup-rc.sh &

  > cat startup-hub.sh
  cd .../selenium-grid-1.0.6/
  ant launch-hub

  > cat startup-rc.sh
  cd .../selenium-grid-1.0.6/
  ant \
    -Dport=5555 \
    -Dhost= \
    -DhubURl= \
    -Denvironment='Firefox on Linux' \

You can see how the server's environment is defined as 'Firefox on Linux'.
Note also that the server is told the location of the hub so that it can
register itself.  You can see the hub's status by pointing a browser at
/console on the same URL (so in my example above).

I can then run a test:

  > ant -Dbrowser="Firefox on Linux" run-in-sequence
  Buildfile: build.xml

       [java] [Parser] Running:
       [java]   Selenium Grid Tests In Sequence
       [java] 11-Aug-2010 15:45:52 com.thoughtworks.selenium.grid.tools.ThreadSafeSeleniumSessionStorage startSeleniumSession
       [java] INFO: Contacting Selenium RC at
       [java] 11-Aug-2010 15:45:59 com.thoughtworks.selenium.grid.tools.ThreadSafeSeleniumSessionStorage startSeleniumSession
       [java] INFO: Got Selenese session:com.thoughtworks.selenium.DefaultSelenium@...
       [java] 11-Aug-2010 15:46:16 com.thoughtworks.selenium.grid.tools.ThreadSafeSeleniumSessionStorage closeSeleniumSession
       [java] INFO: Closing Selenese session: com.thoughtworks.selenium.DefaultSelenium@...
       [java] ===============================================
       [java] Selenium Grid Tests In Sequence
       [java] Total tests run: 1, Failures: 0, Skips: 0
       [java] ===============================================

  Total time: 23 seconds

I will explain how tests are written and structured, but first I need to add
one extra point.  There's an additional piece of information needed, which is
the "driver" used to run the tests.  This depends on the browser, and so we
need to map from environment to driver.  This is done in the file
grid_configuration.yaml in the main selenium-grid directory and displayed in
the hub console display.

So far I have addressed my point (1), but haven't really explain how (2) is
solved.  And in truth, I don't completely know - I am simply copying some code
that works.

However, I do know that the documentation is *particularly* poor on this, so
this information is critical.

First, the ant scripts use TestNG to run Java tests.  But the tests generated
by the IDE (export as Java TestNG) seem sot be using an old, unsupported
library.  Do *not* try hunting down the appropriate class and jar
(SeleneseTestNgHelper) because it does not work with the rest of the
(ant-based) environment, as far as I can see.

Instead, copy the supplied code used in the (broken!) tests in the Selenium
Grid package.  In particular, copy GoogleImageTestBase.java and compare ti to
the code generated by the IDE - it's pretty obvious how to do the translation.

Note that the libraries involved do the necessary work of somehow adapting the
tests to use the parameters supplied to any when invoking with a particular

If you do all that then you will need to link to the following jars:

You will also need a build.xml that can compile that and run the test.  I

  <project name="..." basedir=".">

    <property name="src.dir"     value="${basedir}/src"/>
    <property name="classes.dir" value="${basedir}/classes"/>
    <property name="lib.dir"     value="${basedir}/lib"/>

    <path id="classpath">
      <fileset dir="${lib.dir}" includes="**/*.jar"/>
      <pathelement path="${classes.dir}"/>

    <target name="compile">
      <mkdir dir="${classes.dir}"/>
      <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>

    <property name="webSite" value="" />
    <property name="seleniumHost" value="" />
    <property name="seleniumPort" value="4444" />
    <property name="browser" value="*firefox" />

    <target name="run-in-sequence" description="Run Selenium tests one by one">
      <java classpathref="classpath"
            <sysproperty key="java.security.policy" file="${basedir}/lib/testng.policy"/>
            <sysproperty key="webSite" value="${webSite}" /> 
            <sysproperty key="seleniumHost" value="${seleniumHost}" />
            <sysproperty key="seleniumPort" value="${seleniumPort}" /> 
            <sysproperty key="browser" value="${browser}" /> 

        <arg value="-suitename" />
        <arg value="Selenium Grid Tests In Sequence" />
        <arg value="-d" />
        <arg value="${basedir}/target/reports" />
        <arg value="-testclass"/>
        <arg value="MyClass"/>


which is just a simple copy of the one supplied in the grid package.

I hope that helps!


Windows etc

From: andrew cooke <andrew@...>

Date: Wed, 11 Aug 2010 16:13:46 -0400

I just realised that the post only describes running on Linux.  In case it's
not obvious, what I also do is:

- start a Windows VM
- install Safari, Google Chrome and Opera
- install Java and ant
- install selenium grid
- start 3 servers with environments "Safari in Windows", "Chrome in
  Windows", and "Opera in Windows"
- modify the hub config so it understands those environments and maps them to
  the correct browsers ("drivers")
- disable pop-up blocking in all (important!)
- then, on Linux I can run the test on these, too (the servers are listed on
  the hib, on Linux)


PS Selenium support for Opera appears to be broken at the moment...

Fressia too

From: andrew cooke <andrew@...>

Date: Wed, 11 Aug 2010 17:45:39 -0400

A friend just pointed me at a package called Fressia -
http://fressia.sourceforge.net/ - that another friend wrote (and that I guess
I heard about and then forgot - sorry).  That seems to package Selenium up
into something that you drive via a Python DSL.  It might be a simpler way to
use Selenium and it also appears to be more complete (tests email sending too,
for example).


Firefox uses Proxy with Selenium

From: andrew cooke <andrew@...>

Date: Tue, 17 Aug 2010 13:01:37 -0400

If you are testing with Firefox, and it keeps connecting to your web proxy,
even though there is nothing configured in the browser, check your KDE network
settings!  Selenium builds a Firefox profile based on the proxy defined
there... (this has taken me hours to track down!)


Regarding Firefox Using Company Proxy Settings

From: "Jeffrey A. Aborot" <image.gif@...>

Date: Tue, 09 Aug 2011 13:28:39 +0800

Hi Andrew,

I am trying out Selenium Grid and got stuck with Selenium Grid's demo 
app not being able to get pass our company's proxy server. I tried 
explicitly coding into the demo app's build.xml our company's proxy 
setting yet still selenium launches firefox, asks for authentication, 
and then does nothing with firefox's page empty. Are you referring to 
the same problem in your post "Firefox uses Proxy"?

Thanks in advance.

jeffrey aborot
newbie tester

Re: Regarding Firefox Using Company Proxy Settings

From: andrew cooke <andrew@...>

Date: Fri, 12 Aug 2011 08:10:12 -0400

Sorry, I completely missed your email (just saw this message when I looked at
my web pages!).

I can't be sure, but it sounds like a similar problem.  I was using a proxy
and had that defined in my KDE settings.  When Firefox started it read those
settings and used them.  Since my test server was local, the proxy couldn't
"see" it and so the Firefox client failed to run tests.

To fix it I cleared the settings from KDE.

Unfortunatley I cannot remmeber any more details.  I hope you aleady fixed
this, or that this is not too late to help....


Comment on this post