Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan Passoubady (Kangs) Copy Right: 2008, All rights reserved by Kangeyan Passoubady (Kangs). Republishing requires author’s permission
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 2 Day Creating a Selenium Test Suite 1
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 3 Selenium Concepts Selenium understands two types of files 1.Test Case 2.Test Suite Every test must be contained within a test suite Both test cases and test suites are defined by using simple tables in HTML
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 4 Format of a Selenium Test Selenium HTML Table commands are called Selenese commands Selenese provides simplicity Selenese defined in HTML Table with 3 columns –First Column: Selenium command –Second Column: Required first parameter –Third Column: Optional second parameter
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 5 Selenium Test Writing in HTML Selenium is sensitive to the format of the table All selenium command rows must have three columns or they will not be recognized as commands You can only test URL’s that are in the same domain as the selenium core Separation of concerns is hard – Tests become very dependent on the internal structure of the HTML
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 6 Selenium Test Writing in HTML Selenium Test Cases Can be created in two ways Editing the Basic Test Suite Using Add Test Case Method
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 7 Selenium Test Suite in Hard Way Editing the Basic Test Suite Add Your Test Cases Manually
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 8 Selenium Test Case Example #1 Now go to “C:\BasicSelenium\Week1\Ex” Double click and open “TC_GE_EE.html” in any browser (*1) Open the Test Case in Selenium IDE, Look at the source (*2) Name of the test case Selenium Command First Parameter or Target Optional Second Parameter *2 *1
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 9 Selenium Test Case Example #2 Omitting the template code, Look at the TR value of the table open type textToSearch energy efficient clickAndWait searchSubmit Each row contains one test case step Comments are displayed as it is 1.Record test case 2.Save into your computer 3.If needed manually open and edit the test case steps in a notepad 4.Knowledge of HTML is required
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 10 Record One More Test Case #1 File New Test Case (Make Selenium IDE in Record Mode) Open Go all the way down, click on the “Contact Information” link Click on “Feedback & Inquiries” link –Consumer/Other (Leave the default option) –Select a Subject (Other) –Select a Country (U.A.E) – (type –Comments or Questions (type Just testing) –Submit (click once)
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 11 Record One More Test Case #2 In the result page, highlight “Thank you for taking the time to contact GE” Right Click and Select waitForTextPresent “Thank you for taking the time to contact GE” Highlight “Feel free to continue browsing.” Right Click and Select VerifyTextPresent “Feel free to continue browsing.” Right Click on “GE.com Home Page” link and Select verifyElementPresent “link=GE.com Home Page”
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 12 Record One More Test Case #3 Now Stop recording in Selenium IDE window File Save the test case as “GE_TC2.html” File Save the test suite as “GE_TS1.html” Save both the files in the same location as you stored in the “GE_TC1.html”
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 13 Format of Selenium Test Suite Similar to test cases commands, but points to the Selenium Test Cases A HTML table that points to many test cases Just double Click and open the “ GE_TS1.html ” in any browser. Click the individual test cases.
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 14 Edit Selenium Test Suite If you have only one “test case” in your test suite, Open the “GE_TS1.html” in NotePad. Add a line of code before the end of tag GE Test Case 2 File → Save then Exit. Now you can double click and see the entire test suite in your browser. You can Edit the Test Suite in notepad when you want to –Change the name of the test cases –Add, Remove, and Rename test cases –Arrange order of test cases. Don’t forget to keep all the test cases in the same directory
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 15 Create EE Test Suite #1 This time we’ll use Selenium to create the Test Suite for us. Open Firefox Open Tools Selenium IDE File Open TC_GE_EE.html (*1) *1
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 16 Selenium Test Suite in Easy Way Add Test Cases Using File Menu Option Save Test Suite
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 17 Create EE Test Suite #2 File Add Test Case TC_Google_EE.html (*2) Press Ctrl+D, Select TC_Yahoo_EE.html (*3) *2 *3
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 18 Create EE Test Suite #3 Now Enlarge the Test Case Section You will see all your test cases listed File Save Test Suite As “TS_EE.html” *4 *6 Click here to enlarge *5
Discover the automating power of Selenium Copyright © by Kangeyan Passoubady (Kangs) 19 Create EE Test Suite #4 Now Click on the “Play Entire Test Suite” icon. Congrats!! *6 Click here to play your test suite