Selenium Web Test Tool Training Discover the automating power of Selenium Portnov Computer School presents: Presented by: Kangeyan Passoubady (Kangs) Copy Right: 2008, All rights reserved by Kangeyan Passoubady (Kangs). Republishing requires author’s permission
23
Embed
Selenium Tutorial Day 22 - Quick Tour of Selenium IDE - Advanced Features
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
SeleniumWeb Test Tool Training
Discover the automating power of Selenium
Portnov Computer School presents:
Presented by: Kangeyan Passoubady (Kangs)
Copy Right: 2008, All rights reserved by Kangeyan Passoubady (Kangs). Republishing requires author’s permission
Options Menu Adding a New Format #4Now we have created two new formats:1. Comma Separated Values (CSV)2. Tab Delimited Values (TDV)We’ll get into action to test the new formats
Open any of the existing test cases you have stored by going to File Open GE Test Case1.htmlSelect the Source Tab, what do you see, it is in html format
Options Menu Adding a New Format #5• Go to Format Select CSV Format from the available options• Now look at the source Tab, it is converted into Comma Separated Value
format.• Save by going File Save Test Case As option, GE Test Case1.csv
Select CSV Format
Source is in comma Separated values Format GE Test Case1.csv
Options Menu Adding a New Format #7var SEPARATORS = { comma: ",", tab: "\t"};options = {separator: 'comma'};configForm = '<description>Separator</description>' +
Options Menu Adding a New Format #8function format(testCase, name) { return formatCommands(testCase.commands);}function formatCommands(commands) { var result = ''; var sep = SEPARATORS[options['separator']]; for (var i = 0; i < commands.length; i++) { var command = commands[i]; if (command.type == 'command') { result += command.command + sep + command.target + sep + command.value +
"\n"; } } return result;}
Format an array of commands to the snippet of source.Used to copy the source into the clipboard.
Format Test Case and return the source
Argument 1: testCase Test Case to formatArgument 2: name
Options Menu Adding a New Format #9function parse(testCase, source) { var doc = source; var commands = []; var sep = SEPARATORS[options['separator']]; while (doc.length > 0) { var line = /(.*)(\r\n|[\r\n])?/.exec(doc); var array = line[1].split(sep); if (array.length >= 3) { var command = new Command(); command.command = array[0]; command.target = array[1]; command.value = array[2]; commands.push(command); } doc = doc.substr(line[0].length); } testCase.setCommands(commands);}
Source Line is parsed and in the IDE it is passed as Command, Target and Value
Parse source file and update TestCase.
Throw an exception if any error occurs
Argument 1: testCase Test Case to updateArgument 2: source
Options Menu Adding a STIQ Format #3function format(testCase, name) { return formatCommands(testCase.commands);}
function formatCommands(commands) { var result = ''; var sep = SEPARATORS[options['separator']]; for (var i = 0; i < commands.length; i++) { var command = commands[i]; if (command.type == 'command') {
Options Menu Adding a STIQ Format #4function parse(testCase, source) { var doc = source; var commands = []; var sep = SEPARATORS[options['separator']];//alert("sep"+sep) while (doc.length > 0) { var line = /(.*)(\r\n|[\r\n])?/.exec(doc); var array = line[1].split(sep); if (array.length >= 3) { var command = new Command(); switch (sep) { case '|': command.command = array[1]; command.target = array[2]; command.value = array[3]; break;
See the changes in the array how it retrieves the values to command, target, value, the positions are changed now.
Parse source file and update TestCase.
Throw an exception if any error occurs
Argument 1: testCase Test Case to updateArgument 2: source
Options Menu Adding a STIQ Format #61. Now we’ll put all the functions together in a file2. Name the file as : selenium_IDE_STIQ_Pipe_v1.js3. For your convenience I have placed this file in the
http://www.portnov.com/Selenium/4. Download the file and save into your folder.5. Go to Selenium IDE Options Menu Format Tab6. Press Add button7. Open your selenium_IDE_STIQ_Pipe_v1.js in notepad (right click on the
explorer where you have placed the file, and select Edit Option).8. In notepad, press Ctrl+A (or Edit Select All) to select all the contents of
the file, press Ctrl+C (Edit Copy) to copy and paste in the Selenium IDE format source window.
9. Provide the Name of the format: STIQ10.Press “Ok” button to close the window11.Press “Ok” button to close the Selenium IDE Options12.Now we’ll do a simple test in Google Maps to test the STIQ format.
Options Menu Adding a STIQ Format #71. Go to the below URL:http://maps.google.com/maps2. Type or Cut and Paste the below Address:3. 1580 West El Camino Real, Mountain View, CA 940404. Verify the Text Present “Portnov Computer School”5. Verify the Title “1580 West El Camino Real, Mountain View, CA 94040 -
Google Maps”6. Click on the “Portnov Computer School” link7. VerifyText Present “Ste 12” on the right side inline popup window.8. AssertText “Portnov Computer School” present within the inline popup
window.9. Stop the Recoding in Selenium IDE10.Make sure Selenium IDE Options Menu Format STIQ11.Save the test case, File Save Test Case Google Maps Test
Case1.pipe.txt12.Click and open the file in Notepad