SELENIUM
Introduction:
Selenium is an open source tool for web application testing. Selenium
tests run directly in a browser, just like real users do. It runs in Internet Explorer,
Mozilla Firefox on Windows, Linux, and Macintosh, Safari on the Mac.
But there are certain things the automation engineer needs to be aware of before he
jumps into
understanding selenium. The automation engineer needs to have a basic knowledge of
the
following things:
1. HTML
2. XML
3. Xpaths
4. Document Object Model(DOM)
5. JavaScript (only a basic knowledge on how events are triggered etc.)
6. Any one of the following language to build a full-fledged test suite – Perl, Python,
Ruby,
Java, C#, PHP.
7. Basic object oriented programming concepts.
What is Selenium?
Acceptance Testing tool for web-apps
 Tests run directly in browser
 Selenium can be deployed on Windows, Linux, and Macintosh.
 Implemented entirely using browser technologies -
o JavaScript
o DHTML
o Frames
Selenium Types:
There are 4 types in Selenium, each for a specific purpose. They are as follows:
1. Selenium IDE
2. Selenium Remote Control
3. Selenium Core
4. Selenium Grid
Selenium IDE :
Selenium IDE is a Firefox plugin which is a record replay tool of Selenium. User can
record the
actions performed on the browser and replay it. User also has an option to write his own
scripts,
save the scripts and develop test suites using Selenium IDE.
Selenium Remote Control :
Selenium Remote Control on the other hand is used when more robust scripts are to be
developed. Using any of the languages listed previously user can build test suites which
are
robust and can run on different platforms, unlike IDE which can run scripts only on
Firefox.
Selenium Core :
Selenium Core usage is similar to Selenium RC except that the scripts which use
selenium core
can only be run on the server where the web application is deployed.
Selenium Grid :
Selenium Grid as the name suggests, is used to organize several Selenium RC's and
run the
scripts on different machines from a central location where Selenium Grid is available.
Features of Selenium IDE:
 Record and playback
 Intelligent field selection will use IDs, names, or XPath as needed
 Auto complete for all common Selenium commands
 Walk through test cases and test suites.
 Debug and set breakpoints
 Save tests as HTML, Ruby scripts, or other formats
 Support for Selenium user-extensions.js file
 Option to automatically assert the title of every page
 Rollup common commands
Selenium IDE Installation Steps:
 To install Selenium IDE just goto http://seleniumhq.org/projects/ide/ click
on download Selenium.
 It will be added to your Firefox add-on list.
Commands in Selenium:
 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
Test Runner:
Test Runner allows you to run the test case in a browser loaded with the Selenium-
Core TestRunner. Test runner is invoked by clicking the below Shown button in the
IDE.
Running Options:
 Run a Test Case: Click the Run button to run the currently displayed test case.
 Run a Test Suite: Click the Run All button to run all the test cases in the currently
loaded test suite.
 Stop and Start: The Pause button can be used to stop the test case while it is
running. The icon of this button then changes to indicate the Resume button. To
continue click Resume.
 Stop in the Middle: Set a breakpoint in the test case to cause it to stop on a
particular command. This is useful for debugging your test case. To set a
breakpoint, select a command, right-click, and from the context menu select
Toggle Breakpoint.
 Start from the Middle: We can set the IDE to begin running from a specific
command in the middle of the test case. This also is used for debugging. To set a
start point, select a command, right-click, and from the context menu select
Set/Clear Start Point.
 Run Any Single Command: Double-click any single command to run it by itself.
This is useful when writing a single command. It lets you immediately test a
command you are constructing, when you are not sure if it is correct. You can
double-click it to see if it runs correctly. This is also available from the context
menu.
Assertion Statements:
 assertTextPresent : This will assert if the text is present in the page.
 assertText: This will assert if a particular element is having the particular text.
 assertTitle: This will assert if the page is having a proper title.
 assertValue: This will assert if a Text box or check box has a particular value
 assertElementPresent: This will assert if a particular UI Element is present in the
page.
Explain Selenium WaitForCommands ?
 waitForPageToLoad : This command will make the script to wait till the page
loads.Syntax is waitForPageToLoad(timeout); Time out is the maximum time the
script will wait for the page to load.
 waitForAlert : This command will wait for the alert message to appear
 waitForTable: This command will wait for the Web table to completely load in the
page
 waitForTitle: This command will for the page Title to appear on the browser.
 Other waitForcommands : Selenium has several other wait command
like waitForText,waitForPopup and so on. These commands are generically
called Synchronization commands
Advantages:
 Supports C#, Java, PHP, Perl, Phython
 Supported on Windows, Linux and Mac OS
 Highly active developer community - backed by Google
 Powerful methods to locate elements (Xpath, CSS, DOM)
Disadvantages
 Challenges running on browsers other than Firefox
 Difficulty to automate AJAX
 Limitations to automate Applets, MS and Desktop Applications

Selenium introduction and some feautures

  • 1.
    SELENIUM Introduction: Selenium is anopen source tool for web application testing. Selenium tests run directly in a browser, just like real users do. It runs in Internet Explorer, Mozilla Firefox on Windows, Linux, and Macintosh, Safari on the Mac. But there are certain things the automation engineer needs to be aware of before he jumps into understanding selenium. The automation engineer needs to have a basic knowledge of the following things: 1. HTML 2. XML 3. Xpaths 4. Document Object Model(DOM) 5. JavaScript (only a basic knowledge on how events are triggered etc.) 6. Any one of the following language to build a full-fledged test suite – Perl, Python, Ruby, Java, C#, PHP. 7. Basic object oriented programming concepts. What is Selenium? Acceptance Testing tool for web-apps  Tests run directly in browser  Selenium can be deployed on Windows, Linux, and Macintosh.  Implemented entirely using browser technologies - o JavaScript o DHTML o Frames Selenium Types: There are 4 types in Selenium, each for a specific purpose. They are as follows: 1. Selenium IDE 2. Selenium Remote Control 3. Selenium Core 4. Selenium Grid Selenium IDE : Selenium IDE is a Firefox plugin which is a record replay tool of Selenium. User can record the
  • 2.
    actions performed onthe browser and replay it. User also has an option to write his own scripts, save the scripts and develop test suites using Selenium IDE. Selenium Remote Control : Selenium Remote Control on the other hand is used when more robust scripts are to be developed. Using any of the languages listed previously user can build test suites which are robust and can run on different platforms, unlike IDE which can run scripts only on Firefox. Selenium Core : Selenium Core usage is similar to Selenium RC except that the scripts which use selenium core can only be run on the server where the web application is deployed. Selenium Grid : Selenium Grid as the name suggests, is used to organize several Selenium RC's and run the scripts on different machines from a central location where Selenium Grid is available. Features of Selenium IDE:  Record and playback  Intelligent field selection will use IDs, names, or XPath as needed  Auto complete for all common Selenium commands  Walk through test cases and test suites.  Debug and set breakpoints  Save tests as HTML, Ruby scripts, or other formats  Support for Selenium user-extensions.js file  Option to automatically assert the title of every page  Rollup common commands Selenium IDE Installation Steps:  To install Selenium IDE just goto http://seleniumhq.org/projects/ide/ click on download Selenium.  It will be added to your Firefox add-on list. Commands in Selenium:  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
  • 3.
    Test Runner: Test Runnerallows you to run the test case in a browser loaded with the Selenium- Core TestRunner. Test runner is invoked by clicking the below Shown button in the IDE. Running Options:  Run a Test Case: Click the Run button to run the currently displayed test case.  Run a Test Suite: Click the Run All button to run all the test cases in the currently loaded test suite.  Stop and Start: The Pause button can be used to stop the test case while it is running. The icon of this button then changes to indicate the Resume button. To continue click Resume.  Stop in the Middle: Set a breakpoint in the test case to cause it to stop on a particular command. This is useful for debugging your test case. To set a breakpoint, select a command, right-click, and from the context menu select Toggle Breakpoint.  Start from the Middle: We can set the IDE to begin running from a specific command in the middle of the test case. This also is used for debugging. To set a start point, select a command, right-click, and from the context menu select Set/Clear Start Point.  Run Any Single Command: Double-click any single command to run it by itself. This is useful when writing a single command. It lets you immediately test a command you are constructing, when you are not sure if it is correct. You can double-click it to see if it runs correctly. This is also available from the context menu. Assertion Statements:  assertTextPresent : This will assert if the text is present in the page.  assertText: This will assert if a particular element is having the particular text.  assertTitle: This will assert if the page is having a proper title.  assertValue: This will assert if a Text box or check box has a particular value  assertElementPresent: This will assert if a particular UI Element is present in the page.
  • 4.
    Explain Selenium WaitForCommands?  waitForPageToLoad : This command will make the script to wait till the page loads.Syntax is waitForPageToLoad(timeout); Time out is the maximum time the script will wait for the page to load.  waitForAlert : This command will wait for the alert message to appear  waitForTable: This command will wait for the Web table to completely load in the page  waitForTitle: This command will for the page Title to appear on the browser.  Other waitForcommands : Selenium has several other wait command like waitForText,waitForPopup and so on. These commands are generically called Synchronization commands Advantages:  Supports C#, Java, PHP, Perl, Phython  Supported on Windows, Linux and Mac OS  Highly active developer community - backed by Google  Powerful methods to locate elements (Xpath, CSS, DOM) Disadvantages  Challenges running on browsers other than Firefox  Difficulty to automate AJAX  Limitations to automate Applets, MS and Desktop Applications