Installing RSelenese in Selenium IDE

Posted by Alvin Lai on October 30, 2009

Selenium on Rails is just plain awesome, providing an web testing interface that doesn’t interfere with your main code. That said, there’s a Firefox plugin called Selenium IDE that records your actions in Firefox and generates tests for use with Selenium, how cool is that!

The only problem is, Selenium IDE doesn’t output in RSelenese and having to port one of their supported formats (Ruby Selenium) is a pain. So what do you do? Install the RSelenese plugin of course!

Here are the steps:

35aaa9dae09704b6186bf35f150277c2

F1b862385d68c472b8a0dca4758cd1cf

Then paste the following code:


/*
* Selenium on Rails RSelenese format for Selenium IDE
*
* Written by Shinya Kasatani (kasatani at gmail.com)
*/

load('formatCommandOnlyAdapter.js');

function string(value) {
if (value != null) {
value = value.replace(/\\/g, '\\\\');
value = value.replace(/\"/g, '\\"');
value = value.replace(/\r/g, '\\r');
value = value.replace(/\n/g, '\\n');
return '"' + value + '"';
} else {
return '""';
}
}

function underscore(text) {
return text.replace(/[A-Z]/g, function(str) {
return '_' + str.toLowerCase();
});
}

function formatCommand(command) {
var line = underscore(command.command);
if (command.target) {
line += ' ' + string(command.target);
if (command.value) {
line += ', ' + string(command.value);
}
}
return line;
}

this.playable = false;

(Taken from http://wiki.openqa.org/display/SIDE/SeleniumOnRails)

here:

39603dd88dd72866cfb0e2d5b074ff32

If you’d wanna tweak the generated RSelenese code, here’s a handy reference:

http://svn.openqa.org/fisheye/browse/~raw,r=1000/selenium-on-rails/selenium-on-rails/doc/classes/SeleniumOnRails/TestBuilder.html

Enjoy! :)

Trackbacks

Use this link to trackback from your own site.

blog comments powered by Disqus