| 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

Have to add...; Culturally Liberal and Nothing More; Weird Finite / Infinite Result; Your diamond is a beaten up mess; Maths Books; Good Bike Route from Providencia / Las Condes to Panul\; Iain Pears (Author of Complex Plots); Plum Jam; Excellent; More Recently; For a moment I forgot StackOverflow sucked; A Few Weeks On...; Chilean Book Recommendations; How To Write Shared Libraries; Jenny Erpenbeck (Author); Dijkstra, Coins, Tables; Python libraries error on OpenSuse; Deserving Trump; And Smugness; McCloskey Economics Trilogy; cmocka - Mocks for C; Concept Creep (Americans); Futhark - OpenCL Language; Moved / Gone; Fan and USB issues; Burgers in Santiago; The Origin of Icosahedral Symmetry in Viruses; autoenum on PyPI; Jars Explains; Tomato Chutney v3; REST; US Elections and Gender: 24 Point Swing; PPPoE on OpenSuse Leap 42.1; SuperMicro X10SDV-TLN4F/F with Opensuse Leap 42.1; Big Data AI Could Be Very Bad Indeed....; Cornering; Postcapitalism (Paul Mason); Black Science Fiction; Git is not a CDN; Mining of Massive Data Sets; Rachel Kaadzi Ghansah; How great republics meet their end; Raspberry, Strawberry and Banana Jam; Interesting Dead Areas of Math; Later Taste; For Sale; Death By Bean; It's Good!; Tomato Chutney v2; Time ATAC MX 2 Pedals - First Impressions; Online Chilean Crafts; Intellectual Variety; Taste + Texture; Time Invariance and Gauge Symmetry; Jodorowsky; Tomato Chutney; Analysis of Support for Trump; Indian SF; TP-Link TL-WR841N DNS TCP Bug; TP-Link TL-WR841N as Wireless Bridge; Sending Email On Time; Maybe run a command; Sterile Neutrinos; Strawberry and Banana Jam; The Best Of All Possible Worlds; Kenzaburo Oe: The Changeling; Peach Jam; Taste Test; Strawberry and Raspberry Jam; flac to mp3 on OpenSuse 42.1; Also, Sebald; Kenzaburo Oe Interview; Otake (Kitani Minoru) move Black 121; Is free speech in British universities under threat?; I am actually good at computers; Was This Mansplaining?; WebFaction / LetsEncrypt / General Disappointment; Sensible Philosophy of Science; George Ellis; Misplaced Intuition and Online Communities; More Reading About Japan; Visibilty / Public Comments / Domestic Violence; Ferias de Santiago; More (Clearly Deliberate); Deleted Obit Post; And then a 50 yo male posts this...; We Have Both Kinds Of Contributors; Free Springer Books; Books on Religion; Books on Linguistics; Palestinan Electronica; Books In Anthropology; Taylor Expansions of Spacetime; Info on Juniper; Efficient Stream Processing; The Moral Character of Crypto; Hearing Aid Info; Small Success With Go!; Re: Quick message - This link is broken; Adding Reverb To The Echo Chamber; Sox Audio Tools

© 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