Oops Null Pointer

Java programming related

Category Archives: Selenium

Selenium pressing or sending End and Home Keys

Quick one: To enumlate the end and home key presses you can use:

selenium.keyPress("somelocator...", "35"); // end
selenium.keyPress("somelocator...", "36"); // home

I need this for a GXT 2.2.3 TreePanel that has nodes that are off the screen (overflow) as GXT nodes are not rendered until they are scrolled into view. This workaround renders all the nodes in the tree.

Selenium Handling / Testing Downloads with a custom profile

Selenium and downloads don’t play nicely as the Firefox (et al) download dialogs are out of reach of Selenium. The GWT application I’m working on allows the user to click on an icon and have an Excel file download initiated.

Searching for ways to test downloading files with Selenium came up with methods focused on running some kind of download dialog GUI interaction tool like AutoIT (anyone tried sikuli?).

While this is a practical solution it feels fragile to me.

To avoid this I created a custom Firefox profile to use as a template. This custom profile contains a customised download save path that I use to check files are downloaded, and a mimetype setting to that Excel files are automatically saved.

To do this:

  • Copy the customProfileDirCUSTFF from the Selenium 1.0.1 sources
  • Add a custom prefs.js file with a download path set (at least)
  • Add a mineTypes.rdf and set excel files to auto save (alwaysAsk=false)
  • Start the selenium server with a template profile parameter

The easiest way to create these files is by changing the settings in Firefox and then looking at the prefs.js file and mimeTypes.rdf file in your profile directory.

The line from the prefs.js is:

user_pref("browser.download.dir", "C:\\temp\\ff_selenium_downloads");

And the section from the mimeTypes:

  <RDF:Description RDF:about="urn:mimetype:handler:application/vnd.ms-excel"
                   NC:alwaysAsk="false" />

To start your Selenium server with the template profile use:


java -jar selenium-server.jar -firefoxProfileTemplate

or in Java:

    RemoteControlConfiguration rcc = new RemoteControlConfiguration();
    server = new SeleniumServer(rcc);