• You can use Selenium-Core and customize everything – deprecated.• But it is easier to just get a Firefox plug-in “Selenium-IDE” that helps you “record” test Cases.• You can record how an app is being used and thenplayback those recordings followed by asserts.• Get everything at: www.openqa.org/selenium/
• Integrated Development Environment for building Selenium test cases.• Operates as a Firefox add-on and provides an interface for developing and running individual test cases or entire test suites.• Selenium-IDE has a recording feature, which will keep account of user actions as they are performed and store them as a reusable script to play back.• It also has a context menu (right-click) integrated with the Firefox browser, which allows the user to pick from a list of assertions and verifications for the selected location.
• Offers full editing of test cases.• Although it is a Firefox only add-on, tests created in it can also be run against other browsers by using Selenium-RC & specifying the name of the test suite on the command line.
Selenium-Grid allows the Selenium-RC solution toscale for test suites or test suites to be run in multipleenvironments.• With Selenium-Grid multiple instances of Selenium- RC are running on various operating system and browser configurations, each of these when launching register with a hub. When tests are sent to the hub they are then redirected to an available Selenium-RC, which will launch the browser and run the test.
This allows for running tests in parallel, with the entiretest suite theoretically taking only as long to run as thelongest individual test.
Selenium-IDESTEP 1 – installation :You can download Selenium IDE from thislocations.http://selenium-ide.openqa.org/download.jsphttps://addons.mozilla.org/en-US/firefox/addon/2079Once the add-on is installed make sure youdo not forget to restart Firefox.
STEP 2 – running a simple test :a. Start Selenium IDE in Firefox: Tools->Selenium IDE. You will see the following popup. The list of actions in the actual test case to execute The root of web application you want to test The log of the events that were executed, including any errors or warning that may have occurred
Execution Record testCommands actionsReference of thecurrently selectedcommand Specify commands, including asserts
b. Click on the red record button on the right.c. Browse to Google.com and enter ‟selenium‟ in the search box and click enter.d. Click on the first result, which is that of selenium.openqa.org.e. Stop the recording by clicking on the record button.You should see something like in next slide.
If you click on the „ Source‟ tab you can see the test html generated by selenium.The „table‟ tab shows the commands recorded by Selenium.
f. Open a new tab in Firefox and click on the Selenium IDE‟s play button to run the recorded test.The IDE should play your recorded test. The IDE after thetest run is shown in next slide. In the „Log section‟ you cansee the various events run by the test. In the table tab youcan see that all the rows are green, which means that the testran successfully.
Now lets add a small assertion to the above test. a. Click on the blank line below after the last „clickAndWait‟ command and insert „assertTextPresent‟ command from the drop down box as shown below. You should see something like this.
This test checks to see if the text „Selenium News‟ is present in the last renderedpage. Run the test again and you should see that the test has run successfully. Notry replacing the text with something that is not present on the page, take forexample „elvis‟ and run the test again. Now the test fails and you should get thescreen below.
Selenium-RCInstallation-Installation is rather a misnomer for Selenium. Selenium has set oflibraries available in the programming language of your choice. Youcould download them from www.openqa.org/selenium/Once you‟ve chosen a language to work with, you simply need to:Install the Selenium RC Server.Set up a programming project using a language specific client driver.Installing Selenium Server-• Ensure that JDK is present on the machine and is in the class path.• The Selenium RC server is simply a Java jar file (selenium-server- standalone-<version-number>.jar), which doesn‟t require any special installation. Just downloading the zip file and extracting the server in the desired directory is sufficient.
Creating a Selenium Test Case in Java• I assume you have Eclipse installed• I assume you have downloaded the Selenium RC 1. The files selenium-server.jar and selenium-java-client- driver.jar will be needed• In Eclipse create a new Java Project 1. Add the selenium-java-<version-number>.jar files to your project as references. 2. Add to your project class path the file selenium-java- <version-number>.jar. 3. Finish• Right click on the src folder and create a new JUnit Test Case• You should now be looking at the JUnit test case class in the editor
• Once you have the server running, in Eclipse you want to run the test case as a JUnit TestFor details on Java test project configuration, see the AppendixsectionsConfiguring Selenium RC With Eclipse SEE DEMO OF TESTRUNNER.HTMLhttp://masivukeni.ccnmtl.columbia.edu/site_media/selenium/TestRunner.html
Run a HTML test suite using Selenium-RCAfter you generated your HTML suite file, you can run the suite using –htmlSuite command.-htmlSuite requires you to specify:* browserString (e.g. "*firefox")* startURL (e.g. "http://www.google.com")* suiteFile (e.g. "c:absolutepathtomyHTMLSuite.html")* resultFile (e.g. "c:absolutepathtomyresults.html")Follow these steps to run the suite:1. Create a HTML file that will keep your test results2. Open a command line3. cd to the selenium-server.jar location.For example: cd E:javaseleniumselenium-server-standalone-2.1.0.jar
4. Run the command with the required arguments. For example java -jar selenium-server.jar -port 4546 -htmlSuite *firefox "http://www.google.com" "c:SeleniumTestTestSuite.html" "C:test.html" You will see how Test runner is invoked and starts running the test in Firefox
In case Test runner does not start running the test cases, ensure pop-upwindows are enabled in your browser.After the test script is done, you can check the test results in the HTML fileyou provided as argument.
How to set up selenium Grid • You will need to download and install the latest Java JRE on your system. You can find this at http://java.sun.com . • You need to check that you have Apache Ant. If you open up a terminal/command prompt and type ant -version. If it doesnt return an error then you should be fine. If it returns an error you will need to download Apache Ant and expand the archive to a folder on hard drive. • You will need to now download Selenium Grid and put that in a folder that is easy to access. Now that we have all the relevant parts installed lets start the grid up. • We are going to start up the Selenium Grid Hub first. Open up a command prompt or terminal and navigate to the folder where the Selenium Grid files are stored.
• From the command prompt run ant launch-hub. This will get the hub running. To see it running put http://localhost:4444/console into a browser and you will be shown a webpage with 3 columns. The first column shows what Environments it can handle, the second column shows what remote controls are available and the third column shows what remote controls are currently running tests. Like the following screenshot
• Now that we have our hub running, lets start up a remote control. Open up another command prompt or terminal and navigate to the Selenium Grid folder. Run ant launch-remote-control. This will launch a Selenium Remote Control for handling Firefox on your OS on port 5555.• We now have a Selenium Grid up and running.Running the Tests in Parallel on Firefox on a Single Machine Now let‟s start three more remote control instances. Launch them in separate terminals: ant -Dport=5556 launch-remote-control ant -Dport=5557 launch-remote-control ant -Dport=5558 launch-remote-control You should now see a total of four remote controls available in the Hub console http://localhost:4444/console:
Available Remote Controls Host Port Environment localhost 5555 *firefox localhost 5556 *firefox localhost 5557 *firefox localhost 5558 *firefoxLaunch the tests in parallel in a new terminal:ant run-demo-in-parallel
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.