selenium automation

21
Introduction to Selenium IMRAN SARWAR Senoir SQA

Upload: imran164

Post on 08-Jan-2017

382 views

Category:

Documents


1 download

TRANSCRIPT

Introduction to Selenium

IMRAN SARWARSenoir SQA

INTRODUCTION TO SELENIUM1) Selenium is a suite of software tools to automate web browsers. Selenium is not just a single tool, but a suite of software's, each catering to different testing needs of an organization. Works anywhere JavaScript is supported. All you need to really know is HTML to start using it right away.

2) Selenium automates web based applications only , It doesn’t automate Desktop applications.UFT (Formerly QTP) can automate Desktop and web applications.)

3) It is open source software.( Anybody can download and use Selenium suite of tools with free of cost, but UFT,RFT … are Vendor tools )

4) Selenium supports various operating environments.Windows , UNIX, Macintosh etc…(UFT / QTP support windows operating environment only.)

2

5) Selenium supports various browsers,Mozilla FirefoxGoogle chromeMs Internet ExplorerOperaSafari etc…

6) Selenium supports various programming languages to enhance Test Cases.Java,C#PerlPythonPHPRuby

3

JAVA PROGRAMMING FOR SELENIUM7) We can use anyone supporting programming language for enhancing test cases, We Select Java Language.)Why Java for Selenium?Most of the Selenium developers (nearly 77 %) use Java and more help documentation and implementations available for Java.Select Selenium Web Driver + Java programming (Core Java – Java Fundamentals and OOPS) + TestNG Framework.

Selenium WebDriver -for identifying elements (objects) and performing operations on elements.

Java programming – for enhancing test cases.

TestNG – for providing Test reports, grouping Test cases, Data driven Testing and parallel test execution. 4

HISTORY OF SELENIUM PROJECT In 2004 invented by Jason R. Huggins and team. He create a JavaScript program which control browser actions. Original name is JavaScript Functional Tester [JSFT] or JavaScript Test Runner. Open source browser based integration test framework built

originally by Thought works. 100% JavaScript and HTML. Selenium first came to life in 2004. RC was developed by Paul hammant. WebDriver interface was launched at Google in 2006. In 2008, WebDriver merged with Selenium RC, called as Selenium

2.0 Selenium IDE + Selenium RC + Selenium Grid - Selenium 1.0 Selenium IDE + [( Selenium RC + Selenium WebDriver ) merged

] + Selenium Grid - Selenium 2.0

5

SELENIUM LICENSE All Selenium projects released under the license of Apache 2.0

Anybody can download and use all Selenium tools with free of cost.

Anybody can modify the source code.

Anybody can distribute the source code.

Selling the modified code is not allowed.

6

SELENIUM SUPPORTING PLATFORMS / ENVIRONMENTS.a) Application EnvironmentIt doesn’t support CUI based Application.It doesn’t support I-tier and II –Tier Applications (Desktop or Windows based Application) It supports web Applications (III- Tier to N-Tier) It supports Mobile Applications which are having web forms.

b) Operating EnvironmentIt supports MS Windows operating environment.It supports UNIX operating environment.It supports Mac operating environment.

c) Web BrowsersSupports Mozilla FirefoxSupports IE Supports Google chrome & Safari , Opera etc…

7

SELENIUM SUITE FOR TOOLS / SELENIUM COMPONENTS.Selenium is not just a single tool, but a suite of software's, each catering to different testing needs of an organization.

a)Selenium IDE.

a) Selenium RC << Selenium Core (*out dated)

Selenium Web-Driver

Selenium Grid

8

SELENIUM IDE It is a Firefox plug in. It is prototyping tool. Ability to run whole suites of tests or individual tests Ability to step through individual tests 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". 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. 9

FEATURES OF SELENIUM IDE:- Record and Playback Test cases. Type Test cases/test scripts using element locators and

Selenese commands / Selenium IDE commands. Edit Test cases. Execute test suites. debugging Test Cases. Export test cases to other formats (programming languages) Selenium IDE Test case format is (.html )

Drawbacks of Selenium IDE:- It support Firefox browser only. It is prototyping tool, not suitable for complex test cases. No programming support (No conditional and Loop statements

etc…) Data Driven Testing is not possible. No detailed Test Reports (It provides summary only).

10

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.

11

SELENIUM WEB-DRIVER  Web-Driver is a name of API. It is a Programming interface,(It doesn’t have IDE) Web-Driver features: Create Test Cases / Test scripts using Elements locators and

Methods. It support conditional and Loop statements, (Variables, operators, Arrays, strings, Methods, Flow control

statements, Methods and OOPS concepts) IT supports Java, C#, Perl, Python, Ruby and PHP languages for

enhancing Test Cases. Data driver testing is possible. Cross browser testing is possible.

Drawbacks It doesn’t generate Test Reports. 12

SELENIUM WEB-DRIVER Selenium WebDriver is a programming interface that allows

the user to develop new and more advanced selenium scripts, while using the most advanced programming languages that available (C#, PHP, Java Etc.).

The WebDriver component is more advanced that other components that come with the selenium suite suggest the Selenium RC/IDE, the main reasons:

This component allows you to develop directly against the web browser because it’s has the power to communicate directly to any selected web browser that supported via selenium.

The communication for controlling the browser can be chosen from all the major coding languages that available (WebDriver is created to support almost any object oriented frameworks). 

Selenium WebDriver is usually compared against the selenium RC.

13

SELENIUM GRID Selenium Grid 2.0 supports Selenium Web-Driver test cases. It is used to grouping Test cases. It is used to execute Test cases in parallel. Generate Test Reports.

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

SELENIUM VERSUS UFT Selenium1) Open Source, No license cost.2) Selenium supports Web Applications only.3) Support Firefox, IE, Chrome, Safari, Opera etc…4) Supports Java, C#, PHP, Perl, Python, and Ruby.5) Use Element locators.6) Supports Windows, UNIX, and Macintosh etc…7) Limited support for image testing.8) Difficult to use.9) No reliable Technical support.10) New features may not work properly.11) No object Repository, so no centralized maintenance of

objects (elements) 12) No authorized certification.13) No integration with other tools. 15

UFT (FORMERLY QTP)1) Vendor tool (HP), License.2) Supports Desktop/windows based and Web Applications.3) IE, Firefox and Chrome.4) VBScript only.5) Based on add ins6) MS Windows operating environment only.7) Rich support for Image Testing and Easy to use.9) HP provides Technical Support.10) New features will work properly.11) Centralized maintenance of Objects.12) HP Conducts certification exam.13) UFT can be integrated with ALM/QC for Test Management.UFT SeleniumTest/Test Script Test Case / Test ScriptObject ElementProperty Locator

16

ADVANTAGES OF SELENIUM It is open source, anybody can download and use. It supports various programming languages for enhancing Test

cases. It supports various operating environments. It supports parallel test execution. It supports various browsers. It uses less hardware resource. Disadvantages of Selenium Since it is Open source software, no reliable technical support. It doesn’t support Desktop applications. Limited support for Image Testing. No centralized maintenance of elements/objects. Difficult to use when it compare to Vendor tools (Ex: UFT,

FT,etc) New features may not work properly. No integration with other tools for Test management.

17

CHOOSE SELENIUM TOOLS Choose Selenium IDE (If you don’t have programming knowledge) Or Choose Selenium Web driver (If you have programming knowledge Choose Java for programming. Firebug and Fire path plug ins to inspect elements for Firefox

browser. If it is IE or Chrome built-in developer tools available (F12) TestNG Framework to execute Test batches and Generate Test

reports.

Example:-Edit box – Element / Objectid – LocatorEmail – ValueMethod / Operation – Entering a Value (ex: [email protected])18

STEPS TO START WITH SELENIUM1) 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 Web-Driver:- Web Driver runs your tests in multiple browsers and platforms. Tweak your tests in your preferred language.

3) Deploy: scale out, speed upSelenium Grid:- extends Selenium Web driver to distribute your tests across multiple servers, saving you time by running tests in parallel.

19

FRAMEWORKS AND PLUGINS USED IN SELENIUMFrameworks:-1) JUnitIt is a framework for Unit testing and it can be used for Selenium Functional tests also.It is used to execute test batches and generate Test Reports.

2) TestNGGrouping Test cases and Execute test groups.Generate HTML test reports.Parallel Test execution.

Plugins used in Selenium1) Firebug and Fire path for inspecting elements, It is for Firefox browser.Note: For IE and Google Chrome built in developers tools available (F12)

20

CONFIGURE OF SELENIUM Java, Selenium Web Driver, TestNG Download and Java (JDK) and install Set Environment (path) variable path to access Java software

from any directory. Download Eclipse IDE (To write and execute Java programs) Download and install Web Driver (Java bindings) from

www.selniumhq.com and add Web driver jar files to Java project (in Eclipse)

Download and install Firebug and Fire path plug ins to inspect elements in Firefox browser.

Download IE, Chrome etc…Browsers drivers (If you want execute test cases on IE and Chrome browsers.)

Note: Firefox browser driver is built- in in Selenium Web driver. Download and install TestNG from Eclipse IDE.

21