SlideShare ist ein Scribd-Unternehmen logo
1 von 19
What is Selenium for?

It is used for functional or system testing web applications. These tests are also sometimes called
acceptance, customer, or integration tests. Selenium is not meant for unit testing.

What is Selenium?

Selenium is a robust set of tools that supports rapid development of test automation for web-based
applications.

    •   Works anywhere JavaScript is supported

    •   Hooks for many other languages - Java, Ruby, Python

    •   Can simulate a user navigating through pages and then assert for specific marks on the pages

    •   All you need to really know is HTML to start using it right away

    •   You can use open source - Selenium tool

    •   Selenium IDE is a plug-in to Firefox to record and playback tests (like WinRunner, QTP).

    •   You can then export the recorded test in most language e.g. HTML, Java, .NET , Perl , Ruby etc.

    •   The exported test can be run in any browser and any platform using "selenium remote control".

    •   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 then playback those recordings followed by
        asserts.

    •   Get everything at: www.openqa.org/selenium/

Selenium-IDE

    •   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-RC (Remote Control)

    •   Selenium-RC provides an API (Application Programming Interface) and library for each of its
        supported languages: HTML, Java, C#, Perl, PHP, Python, and Ruby.

    •   This ability to use Selenium-RC with a high-level programming language to develop test cases
        also allows the automated testing to be integrated with a project’s automated build environment.

Selenium-Grid

Selenium-Grid allows the Selenium-RC solution to scale for test suites or test suites to 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.

Steps to start with Selenium

1) Begin: write and run tests in Firefox.

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.

2) Customize: your language, your browser.

Selenium Remote Control (RC) runs your tests in multiple browsers and platforms. Tweak your tests in
your preferred language.

3) Deploy: scale out, speed up

Selenium Grid extends Selenium RC to distribute your tests across multiple servers, saving you time by
running tests in parallel.

    •   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.

Running Selenium Server

Before starting any tests you must start the server. Go to the directory where Selenium RC’s server is
located and run the following from a command-line console.

java -jar selenium-server.jar

This can be simplified by creating a batch or shell executable file (.bat on Windows and .sh on Linux)
containing the command above. Then make a shortcut to that executable on your desktop and simply
double-click the icon to start the server.

For the server to run you’ll need Java installed and the PATH environment variable correctly configured to
run it from the console. You can check that you have Java correctly installed by running the following on a
console:

java -version

If you get a version number (which needs to be 1.5 or later), you’re ready to start using Selenium RC.

Using the Java Client Driver

Download Selenium RC from the SeleniumHQ downloads page.

Extract the file selenium-java-client-driver.jar.

Open your desired Java IDE (Eclipse, NetBeans, IntelliJ, Netweaver, 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. The API is presented later in this chapter. You
can either use JUnit, or TestNg to run your test, or you can write your own simple main() program. These
concepts are explained later in this section.

Run Selenium server from the console.

Execute your test from the Java IDE or from the command-line.

Selenium Commands

A command is what tells Selenium what to do. 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.

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.

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", "verify", and " waitFor". For example, you can
"assertText", "verifyText" and "waitForText". When an "assert" fails, the test is aborted. When a "verify"
fails, the test will continue execution, logging the failure. This allows a single "assert" to ensure that the
application is on the correct page, followed by a bunch of "verify" assertions to test form field values,
labels, etc.

"waitFor" commands wait for some condition to become true (which can be useful for testing Ajax
applications). They will succeed immediately if the condition is already true. However, they will fail and
halt the test if the condition does not become true within the current timeout setting (see the setTimeout
action below).

Software Required:

1. eclipse-jdk-3.6.0-win32 [java(TM) SE 6]

2. Selenium IDE

3. selenium-java-client-driver-1.0.1

4. Selenium-server-1.0.3

A simple example: Step 1: Run the server at command prompt
Server is running




Step 2: Create a new project
Project Name: proj01
Step 3: Create a new package
Step 4: Create a new class
Step 5: Create a new folder to link with the external jars
Configure build path
Adding external jars
Adding external jars
Step 6: Adding the library
Adding the library: JUnit 4
Step 7: Record the required scenarios and convert it into JUnit 4 format (Taken google site) using
Selenium IDE
Step 8: Paste the above recorded test script in the java application and modify the class names (say,
untitled to required class names created above)
Step 9: Run the program




At the command prompt, changes will be notified
Observation of the recorded scenario




Status
Sel

Weitere ähnliche Inhalte

Was ist angesagt?

Automated Web Testing Using Selenium
Automated Web Testing Using SeleniumAutomated Web Testing Using Selenium
Automated Web Testing Using SeleniumWeifeng Zhang
 
Mastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsMastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsNick Belhomme
 
Introduction to Selenium
Introduction to SeleniumIntroduction to Selenium
Introduction to SeleniumKnoldus Inc.
 
Selenium – testing tool jack
Selenium – testing tool jackSelenium – testing tool jack
Selenium – testing tool jackJackseen Jeyaluck
 
Smarter ways to do selenium automation @ work, Selenium, automation
Smarter ways to do selenium automation @ work, Selenium, automationSmarter ways to do selenium automation @ work, Selenium, automation
Smarter ways to do selenium automation @ work, Selenium, automationRIA RUI Society
 
Selenium Test Automation - Challenges
Selenium Test Automation - ChallengesSelenium Test Automation - Challenges
Selenium Test Automation - ChallengesArul Selvan
 
Selenium Tutorial
Selenium TutorialSelenium Tutorial
Selenium Tutorialprad_123
 
First steps with selenium rc
First steps with selenium rcFirst steps with selenium rc
First steps with selenium rcDang Nguyen
 
Selenium test automation
Selenium test automationSelenium test automation
Selenium test automationSrikanth Vuriti
 
Basics of Selenium IDE,Core, Remote Control
Basics of Selenium IDE,Core, Remote ControlBasics of Selenium IDE,Core, Remote Control
Basics of Selenium IDE,Core, Remote Controlusha kannappan
 

Was ist angesagt? (19)

Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
Automated Web Testing Using Selenium
Automated Web Testing Using SeleniumAutomated Web Testing Using Selenium
Automated Web Testing Using Selenium
 
Selenium (1)
Selenium (1)Selenium (1)
Selenium (1)
 
Mastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsMastering selenium for automated acceptance tests
Mastering selenium for automated acceptance tests
 
Introduction to Selenium
Introduction to SeleniumIntroduction to Selenium
Introduction to Selenium
 
Selenium – testing tool jack
Selenium – testing tool jackSelenium – testing tool jack
Selenium – testing tool jack
 
Selenium
SeleniumSelenium
Selenium
 
Smarter ways to do selenium automation @ work, Selenium, automation
Smarter ways to do selenium automation @ work, Selenium, automationSmarter ways to do selenium automation @ work, Selenium, automation
Smarter ways to do selenium automation @ work, Selenium, automation
 
Selenium
SeleniumSelenium
Selenium
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium Test Automation - Challenges
Selenium Test Automation - ChallengesSelenium Test Automation - Challenges
Selenium Test Automation - Challenges
 
Selenium Tutorial
Selenium TutorialSelenium Tutorial
Selenium Tutorial
 
First steps with selenium rc
First steps with selenium rcFirst steps with selenium rc
First steps with selenium rc
 
Selenium test automation
Selenium test automationSelenium test automation
Selenium test automation
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Basics of Selenium IDE,Core, Remote Control
Basics of Selenium IDE,Core, Remote ControlBasics of Selenium IDE,Core, Remote Control
Basics of Selenium IDE,Core, Remote Control
 
Selenium
SeleniumSelenium
Selenium
 

Andere mochten auch

Zapatos y bolsos julio
Zapatos y bolsos julioZapatos y bolsos julio
Zapatos y bolsos julioCarlos Andia
 
Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907NodejsFoundation
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 

Andere mochten auch (9)

Sweden vs gb
Sweden vs gbSweden vs gb
Sweden vs gb
 
Sept11 2
Sept11 2Sept11 2
Sept11 2
 
Fauna util
Fauna utilFauna util
Fauna util
 
Zapatos y bolsos julio
Zapatos y bolsos julioZapatos y bolsos julio
Zapatos y bolsos julio
 
Animales
AnimalesAnimales
Animales
 
Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Ähnlich wie Sel

Ähnlich wie Sel (20)

Selenium Testing
Selenium Testing Selenium Testing
Selenium Testing
 
Selenium
SeleniumSelenium
Selenium
 
Selenium by using JAVA
Selenium by using JAVASelenium by using JAVA
Selenium by using JAVA
 
Selenium Automation Using Ruby
Selenium Automation Using RubySelenium Automation Using Ruby
Selenium Automation Using Ruby
 
Selenium
SeleniumSelenium
Selenium
 
Learn SELENIUM at ASIT
Learn SELENIUM at ASITLearn SELENIUM at ASIT
Learn SELENIUM at ASIT
 
Selenium institute in bangalore
Selenium institute in bangaloreSelenium institute in bangalore
Selenium institute in bangalore
 
Selenium
SeleniumSelenium
Selenium
 
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdfLesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
 
Selenium
SeleniumSelenium
Selenium
 
Testing Java Web Apps With Selenium
Testing Java Web Apps With SeleniumTesting Java Web Apps With Selenium
Testing Java Web Apps With Selenium
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Test Automation Using Selenium
Test Automation Using SeleniumTest Automation Using Selenium
Test Automation Using Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With Selenium
 
What is selenium
What is seleniumWhat is selenium
What is selenium
 
Codeception
CodeceptionCodeception
Codeception
 
Selenium (1) (1)
Selenium (1) (1)Selenium (1) (1)
Selenium (1) (1)
 
Selenium
SeleniumSelenium
Selenium
 

Sel

  • 1. What is Selenium for? It is used for functional or system testing web applications. These tests are also sometimes called acceptance, customer, or integration tests. Selenium is not meant for unit testing. What is Selenium? Selenium is a robust set of tools that supports rapid development of test automation for web-based applications. • Works anywhere JavaScript is supported • Hooks for many other languages - Java, Ruby, Python • Can simulate a user navigating through pages and then assert for specific marks on the pages • All you need to really know is HTML to start using it right away • You can use open source - Selenium tool • Selenium IDE is a plug-in to Firefox to record and playback tests (like WinRunner, QTP). • You can then export the recorded test in most language e.g. HTML, Java, .NET , Perl , Ruby etc. • The exported test can be run in any browser and any platform using "selenium remote control". • 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 then playback those recordings followed by asserts. • Get everything at: www.openqa.org/selenium/ Selenium-IDE • 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.
  • 2. Selenium-RC (Remote Control) • Selenium-RC provides an API (Application Programming Interface) and library for each of its supported languages: HTML, Java, C#, Perl, PHP, Python, and Ruby. • This ability to use Selenium-RC with a high-level programming language to develop test cases also allows the automated testing to be integrated with a project’s automated build environment. Selenium-Grid Selenium-Grid allows the Selenium-RC solution to scale for test suites or test suites to 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. Steps to start with Selenium 1) Begin: write and run tests in Firefox. 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. 2) Customize: your language, your browser. Selenium Remote Control (RC) runs your tests in multiple browsers and platforms. Tweak your tests in your preferred language. 3) Deploy: scale out, speed up Selenium Grid extends Selenium RC to distribute your tests across multiple servers, saving you time by running tests in parallel. • 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.
  • 3. 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. Running Selenium Server Before starting any tests you must start the server. Go to the directory where Selenium RC’s server is located and run the following from a command-line console. java -jar selenium-server.jar This can be simplified by creating a batch or shell executable file (.bat on Windows and .sh on Linux) containing the command above. Then make a shortcut to that executable on your desktop and simply double-click the icon to start the server. For the server to run you’ll need Java installed and the PATH environment variable correctly configured to run it from the console. You can check that you have Java correctly installed by running the following on a console: java -version If you get a version number (which needs to be 1.5 or later), you’re ready to start using Selenium RC. Using the Java Client Driver Download Selenium RC from the SeleniumHQ downloads page. Extract the file selenium-java-client-driver.jar. Open your desired Java IDE (Eclipse, NetBeans, IntelliJ, Netweaver, 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. The API is presented later in this chapter. You can either use JUnit, or TestNg to run your test, or you can write your own simple main() program. These concepts are explained later in this section. Run Selenium server from the console. Execute your test from the Java IDE or from the command-line. Selenium Commands A command is what tells Selenium what to do. Selenium commands come in three 'flavors': Actions, Accessors and Assertions.
  • 4. 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. 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. 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", "verify", and " waitFor". For example, you can "assertText", "verifyText" and "waitForText". When an "assert" fails, the test is aborted. When a "verify" fails, the test will continue execution, logging the failure. This allows a single "assert" to ensure that the application is on the correct page, followed by a bunch of "verify" assertions to test form field values, labels, etc. "waitFor" commands wait for some condition to become true (which can be useful for testing Ajax applications). They will succeed immediately if the condition is already true. However, they will fail and halt the test if the condition does not become true within the current timeout setting (see the setTimeout action below). Software Required: 1. eclipse-jdk-3.6.0-win32 [java(TM) SE 6] 2. Selenium IDE 3. selenium-java-client-driver-1.0.1 4. Selenium-server-1.0.3 A simple example: Step 1: Run the server at command prompt
  • 5. Server is running Step 2: Create a new project
  • 7. Step 3: Create a new package
  • 8. Step 4: Create a new class
  • 9. Step 5: Create a new folder to link with the external jars
  • 13. Step 6: Adding the library
  • 15. Step 7: Record the required scenarios and convert it into JUnit 4 format (Taken google site) using Selenium IDE
  • 16. Step 8: Paste the above recorded test script in the java application and modify the class names (say, untitled to required class names created above)
  • 17. Step 9: Run the program At the command prompt, changes will be notified
  • 18. Observation of the recorded scenario Status