SlideShare a Scribd company logo
Connect. Collaborate. Innovate.




                               Web Application Testing
                                  using Selenium


                                      Amit Saxena
                                      17/08/2011



© Copyright GlobalLogic 2010                                                    1
Web Application Testing using Selenium                Connect. Collaborate. Innovate.




    Training Agenda:
              Selenium Introduction
              Selenium Components
              Recording & Testing with Selenium IDE
              Exercise 1 – Selenium IDE
              Testing using Selenium RC
              Exercise 2 – Selenium RC
              Parallel testing using Selenium Grid




© Copyright GlobalLogic 2010                                                             2
Selenium – What is it?                                Connect. Collaborate. Innovate.




    • Selenium is a set of tools to automate web application testing
    across many platforms.
    • Selenium runs in many browsers and operating systems.
    • Selenium can be controlled by many programming languages and
    testing frameworks.
    • Selenium is highly flexible.
    • Selenium is an Open Source project. The code can be modified and
    enhancements can be submitted for contribution.




© Copyright GlobalLogic 2010                                                            3
Selenium Components                                       Connect. Collaborate. Innovate.




         Selenium IDE - is a Firefox add-on that records
        clicks, typing, and other actions to make a test, which you
        can play back in the browser.
         Selenium RC - runs your tests in multiple browsers and
        platforms. Tweak/Customize your tests in your preferred
        programming language.
         Selenium Grid - extends Selenium RC to distribute
        your tests across multiple servers, saving you time by
        running tests in parallel.




© Copyright GlobalLogic 2010                                                                4
Selenium Components…           Connect. Collaborate. Innovate.




© Copyright GlobalLogic 2010                                     5
Platforms Supported by Selenium   Connect. Collaborate. Innovate.




© Copyright GlobalLogic 2010                                        6
Connect. Collaborate. Innovate.
Selenium Commands – Selenese

          Selenium commands come in three “flavors”: Actions, Accessors and
          Assertions.


          Actions are commands that generally manipulate the state of the application. They do things
          like “click this link” and “select that option”. If an Action fails, or has an error, the execution of the
          current test is stopped.

          Accessors examine the state of the application and store the results in variables, e.g.
          “storeTitle”. They are also used to automatically generate Assertions.

          Assertions are like Accessors, but they verify that the state of the application conforms to what
          is expected. Examples include “make sure the page title is X” and “verify that this checkbox is
          checked”.
          All Selenium Assertions can be used in 3 modes:

          Assert – Upon failure test is aborted
          Verify – Upon failure error is logged and test continues
          WaitFor – Waits for a conditions for a given timeout




© Copyright GlobalLogic 2010                                                                                                            7
Connect. Collaborate. Innovate.
Selenium Scripts Syntax


    Selenium commands are simple, they consist of the command and two parameters.
    For example:

        type                         id=phone                      (555) 666-7066

       Parameters vary, however they are typically:
       a locator for identifying a UI element within a page.
       a text pattern for verifying or asserting expected page content
       a text pattern or a selenium variable for entering text in an input field or for selecting
       an option from an option list.




© Copyright GlobalLogic 2010                                                                                                          8
Commonly Used Selenium Commands                                                Connect. Collaborate. Innovate.




 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 it’s 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.




© Copyright GlobalLogic 2010                                                                                     9
Locating Elements                                                                               Connect. Collaborate. Innovate.




  For many Selenium commands, a target is required. This target identifies an element in the
  content of the web application, and consists of the location strategy. Some of the location
  strategies using in Selenium are:
     Locating by Identifier
     This is probably the most common method of locating elements and is the catch-all default when no
     recognized locator type is used. With this strategy, the first element with the id attribute value matching the
     location will be used. If no element has a matching id attribute, then the first element with a name attribute
     matching the location will be used.
     Locating by Id
     This type of locator is more limited than the identifier locator type, but also more explicit. Use this when
     you know an element’s id attribute.
     Locating by Name
     The name locator type will locate the first element with a matching name attribute.
     Locating by XPath
     XPath is the language used for locating nodes in an XML document. As HTML can be an implementation of
     XML (XHTML), Selenium users can leverage this powerful language to target elements in their web
     applications. One of the main reasons for using XPath is when you don’t have a suitable id or name attribute
     for the element you wish to locate. You can use XPath to either locate the element in absolute terms (not
     advised), or relative to an element that does have an id or name attribute.




© Copyright GlobalLogic 2010                                                                                                      10
Selenium IDE                                                          Connect. Collaborate. Innovate.




    Selenium IDE is an integrated development environment for Selenium
    scripts. It is implemented as a Firefox extension, and allows you to
    record, edit, and debug tests.

       Features:
       •Easy record and playback
       •Intelligent field selection will use IDs, names, or XPath as needed
       •Autocomplete for all common Selenium commands
       •Walk through tests
       •Debug and set breakpoints
       •Save tests as Html, Java, .NET, Php, Perl, Ruby scripts etc.
       •Support for Selenium user-extensions.js file




© Copyright GlobalLogic 2010                                                                            11
Selenium IDE Installation                                        Connect. Collaborate. Innovate.




Selenium IDE is installed as a Firefox extension. It can be installed directly within
Firefox by going to http://seleniumhq.org/download/ and downloading
http://release.seleniumhq.org/selenium-ide/1.0.7/selenium-ide-1.0.7.xpi (XPIs are
the Firefox Extensions)




© Copyright GlobalLogic 2010                                                                       12
Opening Selenium IDE                                     Connect. Collaborate. Innovate.




Selenium IDE is opened from the Tools menu of Firefox.




© Copyright GlobalLogic 2010                                                               13
Connect. Collaborate. Innovate.
Selenium IDE Features

              Menu Bar


             Toolbar




                                   Test Case Pane
          Test Case Pane




       Log/Reference Pane




© Copyright GlobalLogic 2010                                     14
Connect. Collaborate. Innovate.
Selenium IDE Basic Toolbar Commands


     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.

       Record: Records the user’s browser actions.

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




© Copyright GlobalLogic 2010                                                                             15
Connect. Collaborate. Innovate.
Building Test Cases using IDE

        Recording
        When Selenium-IDE is first opened, the record button is ON by default.
        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

        Adding Verifications and Asserts With the Context Menu
        Your test cases will also need to check the properties of a web-page. This requires assert and
        verify commands.
        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.
        Insert Commands in Table View or Source View
        Commands can also be inserted in the Table view and Source View manually.




© Copyright GlobalLogic 2010                                                                                          16
Exercise 1 – Selenium IDE                          Connect. Collaborate. Innovate.




  1. Install Selenium IDE
  2. Record & Save the following test cases in Selenium IDE:
      Open Google.com. Search GlobalLogic in Google. Click
     GlobalLogic link in search result. GlobalLogic homepage should
     open up.
      Open GlobalLogic.com. Click About Us. Verify that the About Us
     page opens up.
      Open GlobalLogic.com. Click Careers Page. Go to current
     openings section. Conduct Search. Verify that the search results
     show up.
  3. Execute the above test cases individually in Selenium IDE.
  4. Execute the above created test cases as a test suite in Selenium
     IDE.


© Copyright GlobalLogic 2010                                                           17
Selenium RC                                                            Connect. Collaborate. Innovate.




  Selenium-RC is the solution for tests that need more than simple browser actions
  and linear execution. Selenium-RC uses the full power of programming languages to
  create more complex tests like reading and writing files, querying a database, and
  emailing test results.

    You’ll want to use Selenium-RC whenever your test requires logic not supported by
    Selenium-IDE. What logic could this be? For example, Selenium-IDE does not
    directly support:

             condition statements
             iteration
             logging and reporting of test results
             error handling, particularly unexpected errors
             database testing
             test case grouping
             re-execution of failed tests
             test case dependency
             screenshot capture of test failures



© Copyright GlobalLogic 2010                                                                             18
Selenium RC Components                                Connect. Collaborate. Innovate.




  Selenium-RC components are:

  The Selenium Server which launches and kills browsers, interprets
  and runs the Selenese commands passed from the test program, and
  acts as an HTTP proxy, intercepting and verifying HTTP messages
  passed between the browser and the AUT (Application Under Test).

  Client libraries which provide the interface between each
  programming language and the Selenium-RC Server.




© Copyright GlobalLogic 2010                                                            19
How Selenium RC Works          Connect. Collaborate. Innovate.




© Copyright GlobalLogic 2010                                     20
Installing Selenium RC Server                        Connect. Collaborate. Innovate.




• The Selenium Server is written in Java, and requires the Java
  Runtime Environment (JRE) version 1.5.0 or higher in order to start.
• Go to the http://seleniumhq.org/download/ and download
  selenium RC (Latest version is 1.0.3) -
  http://selenium.googlecode.com/files/selenium-remote-control-
  1.0.3.zip
• Unzip and extract it any directory.




© Copyright GlobalLogic 2010                                                           21
Start the RC Server                               Connect. Collaborate. Innovate.




• Open command prompt and go to the directory where you have
  extracted the Selenium RC.
• Run the command –
  java -jar selenium-server.jar




© Copyright GlobalLogic 2010                                                        22
Using Java Client Driver                                                     Connect. Collaborate. Innovate.




•      Extract the file selenium-java-client-driver.jar from selenium-remote-control-1.0.3.zip
•      Open your desired Java IDE (Eclipse, NetBeans, IntelliJ etc.)
•      Create a new project.
•      Add the selenium-java-client-driver.jar files to your project as references.
•      Add to your project classpath the file selenium-java-client-driver.jar.
•      From Selenium-IDE, export a script to a Java file and include it in your Java project, or write
       your Selenium test in Java using the selenium-java-client API.
•      Run Selenium server from the console.
•      Execute your test from the Java IDE or from the command-line.




© Copyright GlobalLogic 2010                                                                                   23
Exercise 2 – Selenium RC                            Connect. Collaborate. Innovate.




  1. Install Selenium RC.
  2. Create a Java Project in Eclipse and add JUnit and Selenium
     Client Driver in project classpath.
  3. Export Test Cases From Selenium IDE as JUnits.
  4. Export Test Case Suite From Selenium IDE as JUnit Test Suite.
  5. Import the Test Cases in Eclipse.
  6. Start the Selenium Server.
  7. Execute the test cases individually from Eclipse as JUnit.
  8. Execute the test cases as a JUnit Suite from Eclipse.




© Copyright GlobalLogic 2010                                                            24
Selenium Grid                                            Connect. Collaborate. Innovate.




     Selenium-Grid allows the Selenium-RC solution to scale for large
     test suites or test suites that must be run in multiple
     environments.

     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 entire test suite theoretically
     taking only as long to run as the longest individual test.




© Copyright GlobalLogic 2010                                                               25
Typical Selenium Grid Setup    Connect. Collaborate. Innovate.




© Copyright GlobalLogic 2010                                     26
Installing Selenium Grid                             Connect. Collaborate. Innovate.




• Selenium Grid requires the following to be installed:
                   • JDK 1.5 or above
                   • Apache Ant 1.7 or above
• Go to the http://selenium-grid.seleniumhq.org/download.html and
  download Selenium Grid (Latest version is 1.0.8) –
  http://release.seleniumhq.org/selenium-grid/selenium-grid-1.0.8-
  bin.zip
• Unzip and extract it any directory.




© Copyright GlobalLogic 2010                                                           27
Starting Selenium Grid                                                       Connect. Collaborate. Innovate.



  Selenium Grid requires the Hub and RCs to be started :

  Hub
  To start Hub, open command prompt and go to the directory where you have extracted
  Selenium Grid and type:
  ant launch-hub

  RCs
  To start RCs, open command prompt and go to the directory where you have extracted
  Selenium Grid and type:
  ant -Denvironment=“*firefox“ -Dport=5555 launch-remote-control
  ant -Denvironment=“*iexplore” -Dport=5556 launch-remote-control
  The above commands would start RCs on ports 5555 and 5556 for firefox and internet
  explorer environments.

  When having multiple machines for RCs, following parameters should be used to provide the Hub URL and
  RC host:
  ant -Dport=<port> -Dhost=<hostname> -DhubURL=<hub url> launch-remote-control

  Grid Console
  Open http://localhost:4444/console to view the registered RCs and their status.
© Copyright GlobalLogic 2010                                                                                   28
Exercise 3 – Selenium Grid                                 Connect. Collaborate. Innovate.




  1.       Install Selenium Grid.
  2.       Start Selenium Grid & RCs.
  3.       Add Parallel JUnit to the classpath in the Eclipse project.
  4.       Export Test Case Suite From Selenium IDE as JUnit Suite.
  5.       Import the Test Case Suite in Eclipse.
  6.       Execute the Test Case suite using Parallel JUnit from Eclipse.
  7.       View the available/active RCs in Grid Console.




© Copyright GlobalLogic 2010                                                                   29
References                      Connect. Collaborate. Innovate.




    Selenium Documentation
    http://seleniumhq.org/docs/




© Copyright GlobalLogic 2010                                        30
Questions                         Connect. Collaborate. Innovate.




                               ??

© Copyright GlobalLogic 2010                                          31
Connect. Collaborate. Innovate.
Web Application Testing using Selenium




                               Thank You!




© Copyright GlobalLogic 2010                                                  32
Ad

Recommended

Selenium framework faq
Selenium framework faq
testslideshare_yahoo
 
Selenium
Selenium
Batch2016
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance
 
Dev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDET
devlabsalliance
 
Selenium Basics by Quontra Solutions
Selenium Basics by Quontra Solutions
QUONTRASOLUTIONS
 
Selenium Interview Questions and Answers | Selenium Tutorial | Selenium Train...
Selenium Interview Questions and Answers | Selenium Tutorial | Selenium Train...
Edureka!
 
Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...
Selenium IDE Tutorial For Beginners | What Is Selenium IDE? | Selenium Tutori...
Edureka!
 
Selenium corporate-training-in-mumbai
Selenium corporate-training-in-mumbai
vibrantuser
 
Ajit jadhav automation_qa_4_ yrs
Ajit jadhav automation_qa_4_ yrs
Ajit Jadhav
 
Selenium and JMeter
Selenium and JMeter
ArchanaKalapgar
 
Selenium and JMeter Testing
Selenium and JMeter Testing
ArchanaKalapgar
 
Android Automation Testing with Selendroid
Android Automation Testing with Selendroid
Vikas Thange
 
International journal of applied sciences and innovation vol 2015 - no 1 - ...
International journal of applied sciences and innovation vol 2015 - no 1 - ...
sophiabelthome
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Dave Haeffner
 
Selenium training in chennai
Selenium training in chennai
Thecreating Experts
 
C# Security Testing and Debugging
C# Security Testing and Debugging
Rich Helton
 
Testing Java applications with Maveryx
Testing Java applications with Maveryx
Maveryx
 
Eclipse 40 and Eclipse e4
Eclipse 40 and Eclipse e4
Lars Vogel
 
Testing Android applications with Maveryx
Testing Android applications with Maveryx
Maveryx
 
Robotium Tutorial
Robotium Tutorial
Mobile March
 
Expert selenium with core java
Expert selenium with core java
Ishita Arora
 
Android testing
Android testing
Bitbar
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
Lars Vogel
 
Getting Started with Selenium
Getting Started with Selenium
Dave Haeffner
 
Automated testing with selenium prasad bapatla
Automated testing with selenium prasad bapatla
prasadbcs
 
Selenium
Selenium
Kalyan ch
 
Automation Testing
Automation Testing
AbdulImrankhan7
 
Selenium Handbook
Selenium Handbook
Suresh Thammishetty
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
Sel
Sel
Sandeep A R
 

More Related Content

What's hot (16)

Ajit jadhav automation_qa_4_ yrs
Ajit jadhav automation_qa_4_ yrs
Ajit Jadhav
 
Selenium and JMeter
Selenium and JMeter
ArchanaKalapgar
 
Selenium and JMeter Testing
Selenium and JMeter Testing
ArchanaKalapgar
 
Android Automation Testing with Selendroid
Android Automation Testing with Selendroid
Vikas Thange
 
International journal of applied sciences and innovation vol 2015 - no 1 - ...
International journal of applied sciences and innovation vol 2015 - no 1 - ...
sophiabelthome
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Dave Haeffner
 
Selenium training in chennai
Selenium training in chennai
Thecreating Experts
 
C# Security Testing and Debugging
C# Security Testing and Debugging
Rich Helton
 
Testing Java applications with Maveryx
Testing Java applications with Maveryx
Maveryx
 
Eclipse 40 and Eclipse e4
Eclipse 40 and Eclipse e4
Lars Vogel
 
Testing Android applications with Maveryx
Testing Android applications with Maveryx
Maveryx
 
Robotium Tutorial
Robotium Tutorial
Mobile March
 
Expert selenium with core java
Expert selenium with core java
Ishita Arora
 
Android testing
Android testing
Bitbar
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
Lars Vogel
 
Getting Started with Selenium
Getting Started with Selenium
Dave Haeffner
 
Ajit jadhav automation_qa_4_ yrs
Ajit jadhav automation_qa_4_ yrs
Ajit Jadhav
 
Selenium and JMeter Testing
Selenium and JMeter Testing
ArchanaKalapgar
 
Android Automation Testing with Selendroid
Android Automation Testing with Selendroid
Vikas Thange
 
International journal of applied sciences and innovation vol 2015 - no 1 - ...
International journal of applied sciences and innovation vol 2015 - no 1 - ...
sophiabelthome
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Dave Haeffner
 
C# Security Testing and Debugging
C# Security Testing and Debugging
Rich Helton
 
Testing Java applications with Maveryx
Testing Java applications with Maveryx
Maveryx
 
Eclipse 40 and Eclipse e4
Eclipse 40 and Eclipse e4
Lars Vogel
 
Testing Android applications with Maveryx
Testing Android applications with Maveryx
Maveryx
 
Expert selenium with core java
Expert selenium with core java
Ishita Arora
 
Android testing
Android testing
Bitbar
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
Lars Vogel
 
Getting Started with Selenium
Getting Started with Selenium
Dave Haeffner
 

Similar to GL_Web application testing using selenium (20)

Automated testing with selenium prasad bapatla
Automated testing with selenium prasad bapatla
prasadbcs
 
Selenium
Selenium
Kalyan ch
 
Automation Testing
Automation Testing
AbdulImrankhan7
 
Selenium Handbook
Selenium Handbook
Suresh Thammishetty
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
Sel
Sel
Sandeep A R
 
Selenium
Selenium
eduquer
 
Selenium ppt
Selenium ppt
Aneesh Rangarajan
 
Automatedtestingwithselenium shubham jain
Automatedtestingwithselenium shubham jain
Prashant Gurav
 
Automated_Testing_Selenium
Automated_Testing_Selenium
Jagdish Kaushal
 
Selenium IDE
Selenium IDE
b4usolution .
 
Selenium
Selenium
mdfkhan625
 
Selenium introduction and some feautures
Selenium introduction and some feautures
zahid32
 
Selenium ide made easy
Selenium ide made easy
Narayanan Palani
 
Selenium Concepts
Selenium Concepts
Swati Bansal
 
What is selenium
What is selenium
Pesara Swamy
 
Selenium Testing
Selenium Testing
Shreshtt Bhatt
 
Selenium
Selenium
Rakshitha Raviprakash
 
Selenium
Selenium
Batch2016
 
Selenium
Selenium
Batch2016
 
Ad

More from Pragya Rastogi (20)

Gl android platform
Gl android platform
Pragya Rastogi
 
Qtp questions
Qtp questions
Pragya Rastogi
 
Qtp not just for gui anymore
Qtp not just for gui anymore
Pragya Rastogi
 
Qtp tutorial
Qtp tutorial
Pragya Rastogi
 
Qtp4 bpt
Qtp4 bpt
Pragya Rastogi
 
Get ro property outputting value
Get ro property outputting value
Pragya Rastogi
 
Bp ttutorial
Bp ttutorial
Pragya Rastogi
 
Gl istqb testing fundamentals
Gl istqb testing fundamentals
Pragya Rastogi
 
Gl scrum testing_models
Gl scrum testing_models
Pragya Rastogi
 
My Sql concepts
My Sql concepts
Pragya Rastogi
 
Oops
Oops
Pragya Rastogi
 
Java programming basics
Java programming basics
Pragya Rastogi
 
70433 Dumps DB
70433 Dumps DB
Pragya Rastogi
 
70 433
70 433
Pragya Rastogi
 
70562-Dumps
70562-Dumps
Pragya Rastogi
 
70562 (1)
70562 (1)
Pragya Rastogi
 
32916
32916
Pragya Rastogi
 
70 562
70 562
Pragya Rastogi
 
Mobile testingartifacts
Mobile testingartifacts
Pragya Rastogi
 
Gl qtp day 3 1
Gl qtp day 3 1
Pragya Rastogi
 
Ad

Recently uploaded (20)

Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 

GL_Web application testing using selenium

  • 1. Connect. Collaborate. Innovate. Web Application Testing using Selenium Amit Saxena 17/08/2011 © Copyright GlobalLogic 2010 1
  • 2. Web Application Testing using Selenium Connect. Collaborate. Innovate. Training Agenda:  Selenium Introduction  Selenium Components  Recording & Testing with Selenium IDE  Exercise 1 – Selenium IDE  Testing using Selenium RC  Exercise 2 – Selenium RC  Parallel testing using Selenium Grid © Copyright GlobalLogic 2010 2
  • 3. Selenium – What is it? Connect. Collaborate. Innovate. • Selenium is a set of tools to automate web application testing across many platforms. • Selenium runs in many browsers and operating systems. • Selenium can be controlled by many programming languages and testing frameworks. • Selenium is highly flexible. • Selenium is an Open Source project. The code can be modified and enhancements can be submitted for contribution. © Copyright GlobalLogic 2010 3
  • 4. Selenium Components Connect. Collaborate. Innovate.  Selenium IDE - is a Firefox add-on that records clicks, typing, and other actions to make a test, which you can play back in the browser.  Selenium RC - runs your tests in multiple browsers and platforms. Tweak/Customize your tests in your preferred programming language.  Selenium Grid - extends Selenium RC to distribute your tests across multiple servers, saving you time by running tests in parallel. © Copyright GlobalLogic 2010 4
  • 5. Selenium Components… Connect. Collaborate. Innovate. © Copyright GlobalLogic 2010 5
  • 6. Platforms Supported by Selenium Connect. Collaborate. Innovate. © Copyright GlobalLogic 2010 6
  • 7. Connect. Collaborate. Innovate. Selenium Commands – Selenese Selenium commands come in three “flavors”: Actions, Accessors and Assertions. Actions are commands that generally manipulate the state of the application. They do things like “click this link” and “select that option”. If an Action fails, or has an error, the execution of the current test is stopped. Accessors examine the state of the application and store the results in variables, e.g. “storeTitle”. They are also used to automatically generate Assertions. Assertions are like Accessors, but they verify that the state of the application conforms to what is expected. Examples include “make sure the page title is X” and “verify that this checkbox is checked”. All Selenium Assertions can be used in 3 modes: Assert – Upon failure test is aborted Verify – Upon failure error is logged and test continues WaitFor – Waits for a conditions for a given timeout © Copyright GlobalLogic 2010 7
  • 8. Connect. Collaborate. Innovate. Selenium Scripts Syntax Selenium commands are simple, they consist of the command and two parameters. For example: type id=phone (555) 666-7066 Parameters vary, however they are typically: a locator for identifying a UI element within a page. a text pattern for verifying or asserting expected page content a text pattern or a selenium variable for entering text in an input field or for selecting an option from an option list. © Copyright GlobalLogic 2010 8
  • 9. Commonly Used Selenium Commands Connect. Collaborate. Innovate. 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 it’s 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. © Copyright GlobalLogic 2010 9
  • 10. Locating Elements Connect. Collaborate. Innovate. For many Selenium commands, a target is required. This target identifies an element in the content of the web application, and consists of the location strategy. Some of the location strategies using in Selenium are: Locating by Identifier This is probably the most common method of locating elements and is the catch-all default when no recognized locator type is used. With this strategy, the first element with the id attribute value matching the location will be used. If no element has a matching id attribute, then the first element with a name attribute matching the location will be used. Locating by Id This type of locator is more limited than the identifier locator type, but also more explicit. Use this when you know an element’s id attribute. Locating by Name The name locator type will locate the first element with a matching name attribute. Locating by XPath XPath is the language used for locating nodes in an XML document. As HTML can be an implementation of XML (XHTML), Selenium users can leverage this powerful language to target elements in their web applications. One of the main reasons for using XPath is when you don’t have a suitable id or name attribute for the element you wish to locate. You can use XPath to either locate the element in absolute terms (not advised), or relative to an element that does have an id or name attribute. © Copyright GlobalLogic 2010 10
  • 11. Selenium IDE Connect. Collaborate. Innovate. Selenium IDE is an integrated development environment for Selenium scripts. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests. Features: •Easy record and playback •Intelligent field selection will use IDs, names, or XPath as needed •Autocomplete for all common Selenium commands •Walk through tests •Debug and set breakpoints •Save tests as Html, Java, .NET, Php, Perl, Ruby scripts etc. •Support for Selenium user-extensions.js file © Copyright GlobalLogic 2010 11
  • 12. Selenium IDE Installation Connect. Collaborate. Innovate. Selenium IDE is installed as a Firefox extension. It can be installed directly within Firefox by going to http://seleniumhq.org/download/ and downloading http://release.seleniumhq.org/selenium-ide/1.0.7/selenium-ide-1.0.7.xpi (XPIs are the Firefox Extensions) © Copyright GlobalLogic 2010 12
  • 13. Opening Selenium IDE Connect. Collaborate. Innovate. Selenium IDE is opened from the Tools menu of Firefox. © Copyright GlobalLogic 2010 13
  • 14. Connect. Collaborate. Innovate. Selenium IDE Features Menu Bar Toolbar Test Case Pane Test Case Pane Log/Reference Pane © Copyright GlobalLogic 2010 14
  • 15. Connect. Collaborate. Innovate. Selenium IDE Basic Toolbar Commands 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. Record: Records the user’s browser actions. Step: Allows you to “step” through a test case by running it one command at a time. Use for debugging test cases. © Copyright GlobalLogic 2010 15
  • 16. Connect. Collaborate. Innovate. Building Test Cases using IDE Recording When Selenium-IDE is first opened, the record button is ON by default. 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 Adding Verifications and Asserts With the Context Menu Your test cases will also need to check the properties of a web-page. This requires assert and verify commands. 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. Insert Commands in Table View or Source View Commands can also be inserted in the Table view and Source View manually. © Copyright GlobalLogic 2010 16
  • 17. Exercise 1 – Selenium IDE Connect. Collaborate. Innovate. 1. Install Selenium IDE 2. Record & Save the following test cases in Selenium IDE:  Open Google.com. Search GlobalLogic in Google. Click GlobalLogic link in search result. GlobalLogic homepage should open up.  Open GlobalLogic.com. Click About Us. Verify that the About Us page opens up.  Open GlobalLogic.com. Click Careers Page. Go to current openings section. Conduct Search. Verify that the search results show up. 3. Execute the above test cases individually in Selenium IDE. 4. Execute the above created test cases as a test suite in Selenium IDE. © Copyright GlobalLogic 2010 17
  • 18. Selenium RC Connect. Collaborate. Innovate. Selenium-RC is the solution for tests that need more than simple browser actions and linear execution. Selenium-RC uses the full power of programming languages to create more complex tests like reading and writing files, querying a database, and emailing test results. You’ll want to use Selenium-RC whenever your test requires logic not supported by Selenium-IDE. What logic could this be? For example, Selenium-IDE does not directly support: condition statements iteration logging and reporting of test results error handling, particularly unexpected errors database testing test case grouping re-execution of failed tests test case dependency screenshot capture of test failures © Copyright GlobalLogic 2010 18
  • 19. Selenium RC Components Connect. Collaborate. Innovate. Selenium-RC components are: The Selenium Server which launches and kills browsers, interprets and runs the Selenese commands passed from the test program, and acts as an HTTP proxy, intercepting and verifying HTTP messages passed between the browser and the AUT (Application Under Test). Client libraries which provide the interface between each programming language and the Selenium-RC Server. © Copyright GlobalLogic 2010 19
  • 20. How Selenium RC Works Connect. Collaborate. Innovate. © Copyright GlobalLogic 2010 20
  • 21. Installing Selenium RC Server Connect. Collaborate. Innovate. • The Selenium Server is written in Java, and requires the Java Runtime Environment (JRE) version 1.5.0 or higher in order to start. • Go to the http://seleniumhq.org/download/ and download selenium RC (Latest version is 1.0.3) - http://selenium.googlecode.com/files/selenium-remote-control- 1.0.3.zip • Unzip and extract it any directory. © Copyright GlobalLogic 2010 21
  • 22. Start the RC Server Connect. Collaborate. Innovate. • Open command prompt and go to the directory where you have extracted the Selenium RC. • Run the command – java -jar selenium-server.jar © Copyright GlobalLogic 2010 22
  • 23. Using Java Client Driver Connect. Collaborate. Innovate. • Extract the file selenium-java-client-driver.jar from selenium-remote-control-1.0.3.zip • Open your desired Java IDE (Eclipse, NetBeans, IntelliJ etc.) • Create a new project. • Add the selenium-java-client-driver.jar files to your project as references. • Add to your project classpath the file selenium-java-client-driver.jar. • From Selenium-IDE, export a script to a Java file and include it in your Java project, or write your Selenium test in Java using the selenium-java-client API. • Run Selenium server from the console. • Execute your test from the Java IDE or from the command-line. © Copyright GlobalLogic 2010 23
  • 24. Exercise 2 – Selenium RC Connect. Collaborate. Innovate. 1. Install Selenium RC. 2. Create a Java Project in Eclipse and add JUnit and Selenium Client Driver in project classpath. 3. Export Test Cases From Selenium IDE as JUnits. 4. Export Test Case Suite From Selenium IDE as JUnit Test Suite. 5. Import the Test Cases in Eclipse. 6. Start the Selenium Server. 7. Execute the test cases individually from Eclipse as JUnit. 8. Execute the test cases as a JUnit Suite from Eclipse. © Copyright GlobalLogic 2010 24
  • 25. Selenium Grid Connect. Collaborate. Innovate. Selenium-Grid allows the Selenium-RC solution to scale for large test suites or test suites that must be run in multiple environments. 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 entire test suite theoretically taking only as long to run as the longest individual test. © Copyright GlobalLogic 2010 25
  • 26. Typical Selenium Grid Setup Connect. Collaborate. Innovate. © Copyright GlobalLogic 2010 26
  • 27. Installing Selenium Grid Connect. Collaborate. Innovate. • Selenium Grid requires the following to be installed: • JDK 1.5 or above • Apache Ant 1.7 or above • Go to the http://selenium-grid.seleniumhq.org/download.html and download Selenium Grid (Latest version is 1.0.8) – http://release.seleniumhq.org/selenium-grid/selenium-grid-1.0.8- bin.zip • Unzip and extract it any directory. © Copyright GlobalLogic 2010 27
  • 28. Starting Selenium Grid Connect. Collaborate. Innovate. Selenium Grid requires the Hub and RCs to be started : Hub To start Hub, open command prompt and go to the directory where you have extracted Selenium Grid and type: ant launch-hub RCs To start RCs, open command prompt and go to the directory where you have extracted Selenium Grid and type: ant -Denvironment=“*firefox“ -Dport=5555 launch-remote-control ant -Denvironment=“*iexplore” -Dport=5556 launch-remote-control The above commands would start RCs on ports 5555 and 5556 for firefox and internet explorer environments. When having multiple machines for RCs, following parameters should be used to provide the Hub URL and RC host: ant -Dport=<port> -Dhost=<hostname> -DhubURL=<hub url> launch-remote-control Grid Console Open http://localhost:4444/console to view the registered RCs and their status. © Copyright GlobalLogic 2010 28
  • 29. Exercise 3 – Selenium Grid Connect. Collaborate. Innovate. 1. Install Selenium Grid. 2. Start Selenium Grid & RCs. 3. Add Parallel JUnit to the classpath in the Eclipse project. 4. Export Test Case Suite From Selenium IDE as JUnit Suite. 5. Import the Test Case Suite in Eclipse. 6. Execute the Test Case suite using Parallel JUnit from Eclipse. 7. View the available/active RCs in Grid Console. © Copyright GlobalLogic 2010 29
  • 30. References Connect. Collaborate. Innovate. Selenium Documentation http://seleniumhq.org/docs/ © Copyright GlobalLogic 2010 30
  • 31. Questions Connect. Collaborate. Innovate. ?? © Copyright GlobalLogic 2010 31
  • 32. Connect. Collaborate. Innovate. Web Application Testing using Selenium Thank You! © Copyright GlobalLogic 2010 32