Selenium

  • 16,633 views
Uploaded on

Gives you the basic idea on How to work with Selenium IDE, RC, GRID and Core.

Gives you the basic idea on How to work with Selenium IDE, RC, GRID and Core.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
16,633
On Slideshare
0
From Embeds
0
Number of Embeds
6

Actions

Shares
Downloads
1,344
Comments
0
Likes
14

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Selenium
  • 2. Session Covers
    • 1. Introduction
    • 1.1 Selenium Origins
    • 1.2 Selenium - what is it?
    • 1.3 Selenium Features
    • 2. Selenium Variants
    • 2.1 Selenium IDE
    • 2.2 Selenium Remote Control
    • 2.3 Selenium Grid
    • 2.4 Selenium Core
    • 3. Selenium Concepts
    • 4. Installations
    • 5. How to run selenium Tests
    • 6. Selenium Framework on windows and Linux
    • 7. Tools – Firebug.
  • 3. Selenium Origins
          • Thought work is a global IT outsourcing company which focuses on Agile software development. The company has contributed many open source product and one of the products is called Selenium
          • The story of Selenium starts at 2004 in Chicago by Jason Huggins buildings core made as “JavaScript Test Runner”.
          • They created this core for the testing of an internal time & expenses application written in (python)
          • Selenium is a chemical element in the periodic table that has the symbol Se and atomic number 34.
          • Selenium is a key mineral which protects the body from Mercury toxicity. Selenium compounds medicate Mercury poisoning
          • Many of Selenium developers knew Mercury tools very well
  • 4. Selenium – What it is?
    • Selenium is one of the most powerful open source automation tools for web application testing (even we can say acceptance testing for web application).
    • Primarily developed in Java Script and browser technologies such as DHTML and Frames and hence supports all the major browsers on all the platforms.
          • For example, you can have your automation scripts written for Firefox on Windows and run them on Firefox in Mac.
    • In terms of coverage for platform and browser, Selenium is probably one of the best tool available in the market for web applications.
    • User can customize the selenium tool based on their requirement (code is available for the user).
  • 5. Selenium Features
    • Open Source tool for Web applications
    • Tests Browser Compatibility and system functionality
    • No licensing cost associated with it
    • Customize according to our requirements.
    • Easy to use:
    • a) Test Cases are written in pure HTML
    • b) Clean and Impressive User Interface
      • For example: The scripts written for Firefox on Windows and run them on Firefox in Mac.
    • Selenium supports multi platform and multi browser in terms of coverage.
  • 6. Selenium vs. QTP
    • Selenium :
    • Selenium is Cross Platform Tool.
    • Selenium has lot of Language Bindings like C#, Ruby, Java, Python, Perl etc
    • Selenium is cost free.
    • The default format of testing in Selenium is HTML
    • QTP:
    • QTP is not a Cross Platform Tool
    • QTP supports only VBScript
    • QTP is very expensive
    • QTP can control other types of applications other than web
  • 7. Selenium Disadvantages
    • We cannot be assured of any add-ins which would be required if selenium fails to recognize objects.
    • Also Support provided for Selenium would be very less ( Incase of QTP, HP provides standard solutions and supports to issues).
  • 8. Selenium Supported Platforms
    • Windows:
      • Internet Explorer 6.0+
      • Firefox 0.8 to 2
      • Seamonkey 1.0
      • Opera 8
    • Mac OS X:
      • Safari 1.3+
      • Firefox 0.8 to 1.5
      • Camino 1.0a1
      • Seamonkey 1.0
    • Linux:
      • Firefox 0.8 to 2
      • Konqueror
  • 9. Usage of Selenium
      • Bot mode: Selenium Core
      • HTML Tables
      • Driven mode: Selenium Remote Control (RC)
      • Test cases in language of choice
      • Record mode: Selenium IDE
  • 10. Table or Driver Based
      • Table based approach fine for simple tests.
      • No programming required
      • Doesn't scale – duplication is a major issue.
      • Driver approach better for 'Real' test suite
      • Can develop tests in language of choice:
      • C#, Java, Ruby, Python, Perl
      • Easier data management via DB / Excel
  • 11. Selenium Variants
    • There are four variants of Selenium, which can be used in isolation or in combination to create complete automation suite for your web applications.
      • Selenium IDE
      • Selenium Core
      • Selenium Remote Control
      • Selenium Grid
  • 12. Selenium IDE
    • Selenium IDE is a Firefox plug in, which includes the entire Selenium Core, allows you to record, play back, edit, and debug tests in browser.
    • Selenium IDE is the only flavor of Selenium which allows you to record user actions on browser window.
    • It can also record user actions in most of the popular languages like Java, C#, Perl, Ruby etc. This eliminates the need of learning new vendor scripting language. However to run them in an automated fashion you need to use Selenium Remote Control.
    • Any way selenium default scripts are html (added JavaScript) and that is the script we are going to use it in selenium IDE.
    • The reason for availability of other language is, user can get the scripts for Selenium Remote Control.
  • 13. Contd..
  • 14. Selenium IDE Concepts
    • When you look at the table , there are 3 columns
    • 1. command
    • 2. target
    • 3. value
    • Command: A command is what tells Selenium what to do. Selenium commands come in
    • three flavors:
    • -> Actions
    • -> Accessors
    • -> and Assertions
    • Target : Element Locators tell Selenium which HTML element a command refers to. The
    • format of a locator is: -> locatorType =argument
  • 15. Selenium Actions
    • Selenium Actions represent something a user would do
    • They are helpful in manipulating state of the application
    • Many Actions can be called with the "AndWait" suffix, e.g. "clickAndWait". This suffix tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.
    • Actions generally appear in two forms
    • action , actionandWait
    • ActionandWait assumes a server call and waits for a longer duration
    • 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.
  • 16. Selenium Accessors
    • Accessors examine the state of the application and store the results in variables.
    • Parameter and variable declarations range from simple values to java script evaluation techniques.
    • Store , storeText and storeValue store values for later access.
    • Internally Selenium uses a map called storedVars keyed to the variable names.
    • Ex: "storeTitle". They are also used to automatically generate Assertions.
  • 17. Selenium Accessors contd..
    • Store (Value to store, variable name)
      • Stores a value into variable
      • Constructed using JavaScript evaluation techniques
    • The variables can directly be accessed using $(variable name) syntax
    • JavaScript can be used to create values, entire parameter values are prefixed with 'javaScript{ with a trailing }‘
    • Examples:
    • store(value to store, variable name)
    • storeValue(input Locator, variable name) storeText(element Locator, variable name)
    • storeAttribute(element Locator@ attribute name, variable name)
  • 18. Selenium Assertions
    • Allows user to verify state of the application
    • 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 truth lines for given timeout
    • 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”.
    • Ex: assertText, verifyText and waitForText
  • 19. Element Locators
    • Element Locator Strategies define how Selenium should recognize a particular class of Objects
    • Following are some predefined Locator strategies:
    • Id = @Id
    • Name = @ name
    • Identifier = @Id
    • Dom= JavaScript expression
    • xpath=XPath expression
    • Link= textPattern
    • css=cssSelector Index
  • 20. String Matching Patterns
    • glob:pattern “?” - Represents a single character “*” - Represents a sequence of characters
    • regexp:regexp Match a string using regular expressions
    • exact:string Match a string exactly, without any wild card stuff
    • Default Selenium takes glob
  • 21. Selenium IDE Features
    • Easy record and playback.
    • Debug and set breakpoints.
    • Option to automatically assert the title of every page.
    • Support for Selenium user-extensions.js file
  • 22. Selenium Remote Control (SRC)
    • Selenium Remote Control is a test tool that allows you to write automated web application in any programming language (Java, .NET, Perl, Python, and Ruby, PHP)
    • Selenium Remote Control provides a Selenium Server, which cans automatically start/stop/control, any supported browser.
    • The Selenium Server communicates directly with the browser using AJAX.
    • You can send commands directly to the Server using simple HTTP GET/POST requests;
    • Finally, the Selenium Server acts as a client-configured HTTP proxy, to stand in between the browser and your website.
  • 23. Selenium RC
  • 24. How to Start Selenium Server?
    • The Selenium Server is written in Java, and requires the Java Runtime Environment (JRE) version 1.5.0 or higher in order to start. You may already have it installed. Try running this from the command line:
        • java –version
    • Once you've got Java installed and ready to go, you can start the Selenium Server from the command line like this:
    • Go to /selenium directory/server/
    • Java -jar selenium-server.jar –interactive
    • Let's begin by using Selenium Server to open up a browser. If you're on Windows and want to run your Selenium commands using Internet Explorer, try typing this:
      • cmd=getNewBrowserSession&1=*iexplore&2=http://www.google.com
    • If all goes well, you should see a new browser window starting with the browser of your choice. Back in the Selenium Server command window, you should see the following message:
      • Got result: OK, 260113 on session 260113
  • 25. Selenium Grid
    • Selenium Grid allows you to run Selenium tests in parallel, cutting down the time required for running acceptance tests to a fraction of the total time it currently takes.
    • Selenium Grid runs on top of Selenium Remote Control.
    • To run Selenium Grid, you need Ant 1.7+ to be installed on your system.
  • 26. Selenium Grid
  • 27. Selenium Core
    • Selenium Core is a Test Tool for web applications.
    • Selenium core tests runs directly in a Browser.
    • Written in Pure JavaScript and DHTML.
    • How to start Selenium Core:
    • To use Selenium Core, you need to make it available from the same web server as the application you want to test
    • Normally, this is as simple as extracting the Selenium Core zip file into the Document Root, htdocs, or webroot of your webserver.
    • Then, try to open the TestRunner.html page on your website, which should be in the core/ directory.
  • 28. Selenium Framework in windows and Linux.
    • Requirements to setup a Basic Framework
      • Java
      • Selenium Remote Control
      • Selenium IDE(If required)
      • Eclipse
      • Java and Selenium Remote Control should be up and running.
      • Invoking a browser though Selenium script.
  • 29. Tools - Firebug
    • Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse.
    • Firebug makes it simple to find HTML elements buried deep in the page. Once you've found what you're looking for, Firebug gives you a wealth of information, and lets you edit the HTML live.
    • In any JavaScript-driven website, HTML elements are constantly being created, removed, and modified. Firebug highlights those changes to the HTML in yellow immediately when they occur.
  • 30.
    • Questions !!!
  • 31. References
    • http://seleniumhq.org/
    • www.openqa.org/Selenium
    • Thank You
      • Kalyan. Ch
      • [email_address]