Ben Biddington

Whatever it is, it's not about "coding"

Posts Tagged ‘firewatir

TeamCity build agents and FireWatir

leave a comment »

We have had some issues lately getting our automated acceptance tests running in TeamCity on Firefox.

Our failing tests could open browser windows, but not interact with them — the same behaviour exhibited when the JSSH plugin is missing. And the error reported in TeamCity is like:

Unable to connect to machine : 127.0.0.1 on port 9997.
Make sure that JSSh is properly installed and
Firefox is running with '-jssh' option
(Watir::Exception::UnableToStartJSShException)

This was puzzling because we knew we had installed JSSH.

The problem amounts to ensuring the Firefox JSSH extension is enabled for the correct account.

Build agents, user accounts and desktop (GUI) interaction

Only when Local System Account is selected can you also select the Allow service to interact with the desktop option. The “this account” method does not even allow selection of the checkbox (watch carefully, the checkbox is unchecked when you press apply).

teamcity-buildagent-account-control

Running without GUI does not prevent these types of things happening — they’re just not painted on the screen — so to diagnose issues like these it’s preferable to allow interaction with desktop.

This means running build agents as Local System account.

Solution

Firefox allows adding extensions via command line. So, to enable JSSH for every user on your build agent, download the extension, and then run something like:

$ "C:\Program Files\Mozilla Firefox\firefox -install-global-extension 'path\to\extension'"

You can then run Team City Build Agent Service as Local System user and enable desktop interaction.

References

  • [Windows Local System account] The LocalSystem account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem, so you cannot specify its name in a call to the LookupAccountName function. It has extensive privileges on the local computer, and acts as the computer on the network.
  • [Firefox command line options] Various command line options are be available to perform advanced, troubleshooting or system administration tasks. Installation into the application directory is possible from the command line, intended to be used by administrators on multi-user systems.
  • [How does JSSH work?] FireWatir uses JSSh (TCP/IP JavaScript Shell Server for Mozilla) to drive the FireFox browser. JSSh allows other programs (like telnet) to establish JavaScript shell connections to a running Mozilla process. Once that connection is made, we can send JavaScript commands over the connection, which are executed against the DOM of the page loaded in the browser. JSSh listens on port 9997 by default.

Written by benbiddington

12 May, 2009 at 12:00