Tuesday, November 22, 2011

IDE Features
Menu Bar
The File menu allows you to create, open, and save test case and test suite files. The Edit menu allows copy, paste, delete, undo, and select all operations for editing the commands in your test case. The Options menu allows the changing of settings. You can set the timeout value for certain commands, add user-defined user extensions to the base set of Selenium commands, and specify the format (language) used when saving your test cases. The Help menu is the standard Firefox Help menu; only one item on this menu–UI-Element Documentation–pertains to Selenium-IDE.
Toolbar
The toolbar contains buttons for controlling the execution of your test cases, including a step feature for debugging your test cases. The right-most button, the one with the red-dot, is the record button.


Speed Control: controls how fast your test case runs.


Run All: Runs the entire test suite when a test suite with multiple test cases is loaded.

Run: Runs the currently selected test. When only a single test is loaded this button and the Run All button have the same effect.


Pause/Resume: Allows stopping and re-starting of a running test case.

Step: Allows you to “step” through a test case by running it one command at a time. Use for debugging test cases.

TestRunner Mode: Allows you to run the test case in a browser loaded with the Selenium-Core TestRunner. The TestRunner is not commonly used now and is likely to be deprecated. This button is for evaluating test cases for backwards compatibility with the TestRunner. Most users will probably not need this button.

Apply Rollup Rules: This advanced feature allows repetitive sequences of Selenium commands to be grouped into a single action. Detailed documentation on rollup rules can be found in the UI-Element Documentation on the Help menu.

Record: Records the user’s browser actions.
Test Case Pane
Your script is displayed in the test case pane. It has two tabs, one for displaying the command and their parameters in a readable “table” format.

Recording the first test case

This section walks through recording the first test case with Selenium IDE
• Make sure the Record button in the right end of the toolbar is switched on
• Open https://nightly.olat.unizh.ch/nightly/dmz/
• Enter 'administrator' and the corresponding password and click 'Login'
• This should result in something like this:


The first test case in Selenium IDE
• To rerun the test, click on one of the green Play buttons
A few things Gotchas here Currently, Selenium IDE sometimes has refresh problems and you don't see the recorded steps until you move the mouse into the command table
• Selenium sometimes has troubles catching keyboard input when Firefox does form-autocompletion.
• Sometimes Selenium records 'click' instead of 'clickAndWait' and rerunning fails because of this.
• Selenium-Recording is not always 100% automated - in fact there is quite a bit of manual effort involved and you can do it all manually in Selenium IDE as well. For example: you can easily type 'clickAndWait' in the command field and enter the target link in the target field yourself - instead of relying on the record mechanism
• You can set Breakpoints in Selenium IDE by right clicking on any line and selecting 'Toggle Breakpoint' [B]
• You can run single Selenium commands by double-clicking on a line
Given that you are on the right page, you can let Selenium visualize a UI-Element by clicking on the 'Find' button. It will let the element blink green for a while

Selenium Record and Playback
NOTE: Selenium IDE is used for recording the test case while Selenium RC executes the test. Since Selenium IDE supports only Mozilla Firefox browser, recording the test case cannot be performed in any other browser. For executing the tests Selenium RC supports most of the widely used browsers Internet Explorer, Firefox, Opera, Safari etc for the test case execution.
Check here for the complete list http://seleniumhq.org/about/platforms.html#browsers

Recoding with Selenium IDE
• Open Firefox Browser: View >Sidebar>select ‘Selenium’ ..Selenium IDE is displayed on the left side
• To record a test case (log into your Yahoo mail and logout), enter the url in the browser ‘http://www.mail.yahoo.com’, login using a username & password. Sign out
• All actions will be recorded in Selenium IDE screen. During recording, Selenium-IDE will automatically insert commands into your test case based on your actions. Typically, this will include:
-clicking a link - click or clickAndWait commands
-entering values - type command
-selecting options from a drop-down listbox - select command
-clicking checkboxes or radio buttons - click command



• The script has table view and source view. In the table view, select a command. Details of the command will be displayed.
• Click on source view- by default recoded in HTML format. The format can be changed in Options->Format.

Adding Verifications and Asserts in the Script
With Selenium-IDE recording, go to the browser displaying your test application and right click anywhere on the page. You will see a context menu showing verify and/or assert commands.
• Now, right-click the selected text. The context menu should give you a verifyTextPresent command and the suggested parameter should be the text itself.
• Try right-clicking an image, or a user control like a button or a checkbox. You may need to use ‘Show All Available Commands’ to see options other than verifyTextPresent. Once you select these other options, the more commonly used ones will show up on the primary context menu. For example, selecting verifyElementPresent for an image should later cause that command to be available on the primary context menu the next time you select an image and right-click.

Saving the test case

• In Selenium IDE click ‘Run’ button to execute the test in the browser to verify if the script is working as expected for re iteration
• Now File->Export As Java(TestNG) test case. (The other formats available are PHP, Python,C#,Ruby,Perl,Groovy).
• Savethe file as ‘yahoomail.java’ in the folder F:/selenium/projects/Yahoo/com/testscripts

Selenium Learning Lessons

Installing the Selenium IDE
Steps:-

1.Launch Mozilla Firefox
2.Go to google.co.in and type Selenium IDE and press enter
3.Select the Downloads url from search results
4.Click on the latest version of selenium IDE
5.Firefox will protect you from installing add-ons from unfamiliar locations, so you will need to click ‘Allow’ to proceed with the installation, as shown in the following screenshot.




When downloading from Firefox, you’ll be presented with the following window.






Select Install Now. The Firefox Add-ons window pops up, first showing a progress bar, and when the download is complete, displays the following.




Restart Firefox. After Firefox reboots you will find the Selenium-IDE listed under the Firefox Tools menu.




Opening the IDE
To run the Selenium-IDE, simply select it from the Firefox Tools menu. It opens as follows with an empty script-editing window and a menu for loading, or creating new test cases.




Configure the Olat Map file
We'll go into details about how the Olat Map file works later. Here's how to configure it in Selenium IDE
• Go to Options>Options...

Setting for the Olat Map file in Selenium IDE
• Configure the user-extensions.js file with one of the following paths:
o Copy the nightly generated user-extensions.js from http://nightly.olat.uzh.ch/nightly/raw/doc/user-extensions.js to a local file and configure that local file. Make sure to repeat this often to catch changes in the olat-ui-map!!!
o if you're doing modifications on the map file (see later), build it yourself and configure it, e.g.: C:\eclipse\workspace\seleniumtests\build\classes\user-extensions.js
• Enable 'Remmber base URL'
• Enable 'Record assertTitle automatically'
• Enable 'Record absolute URL'
• Enable 'Enable UI-Element' (important!)
• Restart Selenium IDE (not the whole browser, just Selenium IDE. Activates the UI-Elements)