├── .gitignore ├── README.md └── robotframework-rc.js /.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Selenium IDE Extension: Clipboard Format for Robotframework 2 | 3 | This is a Firefox plugin that adds formatters to Selenium IDE so that scripts can be exported as Robot Framework Keywords. 4 | 5 | ## Installation 6 | 7 | * Open the Selenium IDE 8 | * Go to Options → Options… → Formats 9 | * Add a new format definition with the name “robotframework-rc” 10 | * Copy and paste the contents of the file “robotframework-rc.js” here 11 | 12 | For complete installation instructions have a look at [my blog post](http://blog.codecentric.de). 13 | 14 | ## Examples 15 | 16 | $ Input Text labeltext=Test Value 17 | $ Select From List feldId Test 18 | $ Input Text feldId2 AnotherValue 19 | $ Textfield Should Contain verifyValue feldId Test 20 | 21 | 22 | ## Useful Ressources 23 | [Blog about this Plugin](http://blog.codecentric.de/en/2012/02/recording-robot-framework-keywords-with-selenium-ide/) 24 | 25 | ##coderwall 26 | [![endorse](http://api.coderwall.com/denschu/endorsecount.png)](http://coderwall.com/denschu) 27 | 28 | 29 | -------------------------------------------------------------------------------- /robotframework-rc.js: -------------------------------------------------------------------------------- 1 | //Separator for splitting commands 2 | var SEPARATOR = " "; 3 | 4 | //Mapping for Selenium Commands -> Selenium Robot Keywords 5 | var KEYWORDS = { 6 | type: "Input Text", 7 | select: "Select From List", 8 | verifyValue: "Textfield Should Contain" 9 | }; 10 | 11 | //converts the test case respectively the single command into the target format 12 | function formatCommands(commands) { 13 | var result = ''; 14 | for (var i = 0; i < commands.length; i++) { 15 | var command = commands[i]; 16 | if (command.type == 'command') { 17 | var keyword = KEYWORDS[command.command]; 18 | if(keyword == null){ 19 | keyword = "Call Selenium Api " + command.command; 20 | } 21 | var target = command.target.replace(/id=/, ''); 22 | result += keyword + SEPARATOR + target + SEPARATOR + command.value + "\n"; 23 | keyword = null; 24 | } 25 | } 26 | return result; 27 | } 28 | 29 | //takes the source of the recorded test case and maps it on a test case object 30 | function parse(testCase, source) { 31 | var doc = source; 32 | var commands = []; 33 | while (doc.length > 0) { 34 | var line = /(.*)(\r\n|[\r\n])?/.exec(doc); 35 | var array = line[1].split(SEPARATOR); 36 | if (array.length >= 3) { 37 | var command = new Command(); 38 | command.command = array[0]; 39 | command.target = array[1]; 40 | command.value = array[2]; 41 | commands.push(command); 42 | } 43 | doc = doc.substr(line[0].length); 44 | } 45 | testCase.setCommands(commands); 46 | } 47 | 48 | //delegate to the formatCommands-method 49 | function format(testCase, name) { 50 | return formatCommands(testCase.commands); 51 | } --------------------------------------------------------------------------------