Andrew Cooke | Contents | Latest | RSS | 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

Choochoo Training Diary

Last 100 entries

[Bike] Gearing On The Back Of An Envelope; [Computing] Okular and Postscript in OpenSuse; There's a fix!; [Computing] Fail2Ban on OpenSuse Leap 15.3 (NFTables); [Cycling, Computing] Power Calculation and Brakes; [Hardware, Computing] Amazing Pockit Computer; Bullying; How I Am - 3 Years Post Accident, 8+ Years With MS; [USA Politics] In America's Uncivil War Republicans Are The Aggressors; [Programming] Selenium and Python; Better Walking Data; [Bike] How Fast Before Walking More Efficient Than Cycling?; [COVID] Coronavirus And Cycling; [Programming] Docker on OpenSuse; Cadence v Speed; [Bike] Gearing For Real Cyclists; [Programming] React plotting - visx; [Programming] React Leaflet; AliExpress Independent Sellers; Applebaum - Twilight of Democracy; [Politics] Back + US Elections; [Programming,Exercise] Simple Timer Script; [News] 2019: The year revolt went global; [Politics] The world's most-surveilled cities; [Bike] Hope Freehub; [Restaurant] Mama Chau's (Chinese, Providencia); [Politics] Brexit Podcast; [Diary] Pneumonia; [Politics] Britain's Reichstag Fire moment; install cairo; [Programming] GCC Sanitizer Flags; [GPU, Programming] Per-Thread Program Counters; My Bike Accident - Looking Back One Year; [Python] Geographic heights are incredibly easy!; [Cooking] Cookie Recipe; Efficient, Simple, Directed Maximisation of Noisy Function; And for argparse; Bash Completion in Python; [Computing] Configuring Github Jekyll Locally; [Maths, Link] The Napkin Project; You can Masquerade in Firewalld; [Bike] Servicing Budget (Spring) Forks; [Crypto] CIA Internet Comms Failure; [Python] Cute Rate Limiting API; [Causality] Judea Pearl Lecture; [Security, Computing] Chinese Hardware Hack Of Supermicro Boards; SQLAlchemy Joined Table Inheritance and Delete Cascade; [Translation] The Club; [Computing] Super Potato Bruh; [Computing] Extending Jupyter; Further HRM Details; [Computing, Bike] Activities in ch2; [Books, Link] Modern Japanese Lit; What ended up there; [Link, Book] Logic Book; Update - Garmin Express / Connect; Garmin Forerunner 35 v 230; [Link, Politics, Internet] Government Trolls; [Link, Politics] Why identity politics benefits the right more than the left; SSH Forwarding; A Specification For Repeating Events; A Fight for the Soul of Science; [Science, Book, Link] Lost In Math; OpenSuse Leap 15 Network Fixes; Update; [Book] Galileo's Middle Finger; [Bike] Chinese Carbon Rims; [Bike] Servicing Shimano XT Front Hub HB-M8010; [Bike] Aliexpress Cycling Tops; [Computing] Change to ssh handling of multiple identities?; [Bike] Endura Hummvee Lite II; [Computing] Marble Based Logic; [Link, Politics] Sanity Check For Nuclear Launch; [Link, Science] Entropy and Life; [Link, Bike] Cheap Cycling Jerseys; [Link, Music] Music To Steal 2017; [Link, Future] Simulated Brain Drives Robot; [Link, Computing] Learned Index Structures; Solo Air Equalization; Update: Higher Pressures; Psychology; [Bike] Exercise And Fuel; Continental Race King 2.2; Removing Lowers; Mnesiacs; [Maths, Link] Dividing By Zero; [Book, Review] Ray Monk - Ludwig Wittgenstein: The Duty Of Genius; [Link, Bike, Computing] Evolving Lacing Patterns; [Jam] Strawberry and Orange Jam; [Chile, Privacy] Biometric Check During Mail Delivery; [Link, Chile, Spanish] Article on the Chilean Drought; [Bike] Extended Gear Ratios, Shimano XT M8000 (24/36 Chainring); [Link, Politics, USA] The Future Of American Democracy; Mass Hysteria; [Review, Books, Links] Kazuo Ishiguro - Never Let Me Go; [Link, Books] David Mitchell's Favourite Japanese Fiction; [Link, Bike] Rear Suspension Geometry; [Link, Cycling, Art] Strava Artwork; [Link, Computing] Useful gcc flags; [Link] Voynich Manuscript Decoded; [Bike] Notes on Servicing Suspension Forks

© 2006-2017 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 - 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
  konsole --hold -e &
  sleep 5
  konsole --hold -e &

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

  > cat
  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 startSeleniumSession
       [java] INFO: Contacting Selenium RC at
       [java] 11-Aug-2010 15:45:59 startSeleniumSession
       [java] INFO: Got Selenese session:com.thoughtworks.selenium.DefaultSelenium@...
       [java] 11-Aug-2010 15:46:16 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 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="" 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 - - 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