Wednesday, August 29, 2012

Selenium IDE


 

Selenium IDE

Selenium IDE is a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.
If not the newest version check here for most recent:  http://seleniumhq.org/download/

How to use video: 



Commonly Used Selenium Commands

To conclude our introduction of Selenium, we’ll show you a few typical Selenium commands. These are probably the most commonly used commands for building tests.

open  opens a page using a URL.
click/clickAndWait  performs a click operation, and optionally waits for a new page to load.
verifyTitle/assertTitle  verifies an expected page title.
verifyTextPresent  verifies expected text is somewhere on the page.
verifyElementPresent  verifies an expected UI element, as defined by its HTML tag, is present on the page.
verifyText  verifies expected text and its corresponding HTML tag are present on the page.
verifyTable  verifies a table’s expected contents.
waitForPageToLoad  pauses execution until an expected new page loads. Called automatically when clickAndWait is used.
waitForElementPresent  pauses execution until an expected UI element, as defined by its HTML tag, is present on the page.
SendKey for typing keys into inputs (also type and typekeys work)

Favorite add-on's to IDE

Flow Control:  https://addons.mozilla.org/en-US/firefox/addon/flow-control/

Examples of implemented commands:
gotolabel / label
Unconditional jump
gotolabeltestlabel1
........
labeltestlabel1
gotolabel parameters:
  1. a label to jump to
gotoIf / label
Conditional jump
gotoIf/corrrect caption/i.test( storedVars.pagetext )testlabel1
........
labeltestlabel1
gotoIf parameters:
  1. javascript expression
  2. label to jump to if javascript expression evaluated as true
(obsolete) assertNoFailureOnNextAndGoto / assertNoErrorOnNextAndGoto / label
this command is dropped in extension for Selenium Core v.0.8+
Jump if following command passed
assertNoFailureOnNextAndGototestlabel1
verifyTextelementcorrect page
open./pageneeded.html
labeltestlabel1
while/endWhile
Cycle
store0loop2
whilestoredVars.loop2 < 2
storejavascript{storedVars.loop2++}
endWhile

while parameters:
  1. javascript expression.

Screenshot on Fail: https://addons.mozilla.org/en-US/firefox/addon/screenshot-on-fail-selenium/

Capturing a screen shot on error or failure is a useful ability that has been available to Selenium users via programming languages. Selenium IDE users did not have an easy option so far. My Screenshot on Fail plugin for Selenium IDE makes this available as a single click feature. When the screen shot on fail plugin is enabled, this plugin will automatically grab a screen shot of the complete web page at the point of test failure. The screen shots are captured for the entire web page and give you an opportunity to review the exact state of the web page when the failures occurred. I have uploaded it to the Mozilla Addons website, but the approval process to make it public usually takes a while. The good news is that you can grab it right now from the addons page.
Once you install the plugin, a Screenshot on Fail tool button will be available on the Selenium IDE toolbar. See the screen shot.
Mini user guide for the plugin:
View failure reports
  • Click on the Screenshot on Fail tool button to turn on capturing screen shots on failure.
  • Run your test case or test suite to capture page coverage.
  • Click on the small arrow next to the Screenshot on Fail icon and then click View failure report menu item to open the failure report.
  • This should open all the failure reports or the latest one if you have just executed a test case or test suite.
  • Click on the Screenshot on Fail tool button again to turn off page coverage.

Page Coverage: https://addons.mozilla.org/en-US/firefox/addon/page-coverage-selenium-ide/

Page Coverage plugin for Selenium IDE that get you the page coverage of the Selenium IDE based tests. I have uploaded it to the Mozilla Addons website, but the approval process to make it public usually takes a while. The good news is that you can grab it right now from the addons page.
Once you install the plugin, a Page coverage tool button will be available on the Selenium IDE toolbar. See the screen shot.

Mini user guide for the plugin

  • Click on the Page Coverage tool button to turn on page coverage.
  • Run your test case or test suite to capture page coverage.


    View Page Coverage Reports
  • Click on the small arrow next to the Page coverage icon and then click View Page Coverage menu item to open the page coverage reports.
  • This should open the all page coverage reports or the latest one if you have just executed a test case or test suite.
  • Click on the Page Coverage tool button again to turn off page coverage.

Sample Page Coverage Reports

These reports show the elements that were used in the test.
  
Sample Page Coverage Reports

Known Issues / Notes

  • The last link or button clicked that triggers a page load will not be captured in the page coverage.
  • Using page coverage with this plugin is destructive, i.e. it changes the web page to mark the elements used by the tests . This may sometimes affect your tests. So always run your tests without page coverage to verify the correct results.
  • You will see “Error: Image corrupt or truncated” in the error log almost every time a screen shot is taken. The screen shot is still saved correctly.
  • If you turn on both highlight elements and page coverage at the same time, page coverage will take precedence. You can have them both installed without problems.
To use this plugin, you will need to install Selenium IDE extension of at least version 1.0.4 first. Only in English for now.



No comments:

Post a Comment