Presentation is loading. Please wait.

Presentation is loading. Please wait.

Testing With Selenium - Open source Test Automation Tool

Similar presentations


Presentation on theme: "Testing With Selenium - Open source Test Automation Tool"— Presentation transcript:

1 Testing With Selenium - Open source Test Automation Tool
By: Niranjan Limbachiya #Title

2 Agenda Selenium Origin What is Selenium?
Platform and Browser compatibility Selenium IDE How to work with Selenium IDE? Selenium CORE Testing Application with IDE/CORE? Selenium-RC Way to Test Application in IE Test IE application with PHPUnit DATA-Driven QMetry- Live Example #Title

3 Selenium Origin Selenium is a chemical element in the periodic table that has the symbol Se and atomic number 34 Selenium was developed by team of Programmers and testers at ThoughtWorks to test their web based time and expenses system. Javascript Functional Test Runner was written by Jason Huggins, Paul Gross and Jie Tina Wang, in 2004. #Title

4 What is Selenium and whats it for?
Selenium tests run directly in a browser, just as real users do A java Script Based Open Source Web Testing Tool That Support web 2.0 Application On Multiple Browser And multiple OS No other test tool covers such a wide array of platforms #Title

5 Contd.. Selenium is not meant for unit testing Its used for Functional or system Testing But Not for Performance Testing

6 Platform and Browser compatibility
Supported Platforms: Windows: Internet Explorer 6.0 Firefox 0.8 to 1.5 Mozilla Suite 1.6+, 1.7+ Seamonkey 1.0 Opera 8 Mac OS X: Safari 1.3+ Camino 1.0a1 Linux: Konqueror #Title

7 Driven Mode. Test Case in different Language
Introduction Selenium IDE RC CORE Record Mode Bot Mode: HTML tables Driven Mode. Test Case in different Language

8 Selenium IDE Selenium IDE is an integrated development environment for Selenium tests It is implemented as a Firefox extension. (Note no IE Extension Available) It allows us to record, edit, and debug tests Selenium IDE includes the entire Selenium Core, allowing you to easily and quickly record and play back tests in the actual environment that they will run. Selenium IDE is not only recording tool: it is a complete IDE You can choose to use its recording capability, or you may edit your scripts by hand

9 How to Start work with Selenium IDE?
Download from When you will download selenium IDE with firefox, it should automatically ask you to install the plugin. In case if we downloaded the file with Opera or IE. No problem:

10 Contd.. Open firefox from the menu: Tools ->Add-ons--> Extensions now drag-n-drop the xpi file to the extensions window restart firefox You can see a 'Selenium IDE' entry from your tools menu Note: First, Always we have to record test in IDE with Fire fox, then we could playback in IE using seleniumTest runner and also for Phpunit(RC)

11 IDE

12 Features: Easy record and playback Debug and set breakpoints Autocomplete for all common Selenium commands Save tests as HTML, PHP scripts, or any other format Support for Selenium user-extensions.js file Option to automatically assert the title of every page

13 Selenium-CORE Selenium core is a test tool for web For Web application
Selenium core tests run directly In a browser Just as real users do !! Written in Pure JAVAScript And DHTML

14 How to Start work with 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.

15

16 Live Example Testing Google/QMetry Application with IDE and Core

17 HTA Mode Selenium Core provides an additional mechanism for running automated tests called "HTA mode.“ An hta file is simply an html file but the extension “. hta” means that when we navigated to IE, it will apply same strict security measure Window+Selenium core+IE To run Selenium Core in HTA mode, just double-click on TestRunner.hta, in the /core directory of your Selenium installation.

18 Selenium RC Allow us to write automated web application in any programming language (Java, .NET, Perl, Python, Ruby, PHP) The Selenium Server communicates directly with browser using AJAX Selenium Server acts as a client-configured HTTP proxy, to stand in between the browser and your website. Selenium Remote Control provides a Selenium Server, which cans automatically start/stop/control, any supported browser

19 RC Architecture

20 How to Start Selenium Server
The Selenium Server is written in Java, and requires the Java Runtime Environment (JRE) version 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

21 Contd.. That will start the Selenium Server and allow you to type commands in the command window. After a number of log messages, you should see the following message: Entering interactive mode... type Selenium commands here (e.g: cmd=open&1= 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=

22 Contd.. 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, on session

23 How I Solved this Error?? When I Test Remote Site through PHPUnit then I was getting following error Error: Testing_Selenium_Exception: could not get response form RC I have started My server through following command Java –jar selenium-server.jar -proxyInjectionMode

24 They Keep two automated test windows
ProxyInjectionMode "Proxy injection" mode is a new highly experimental feature for 0.9.0 Normal Mode ProxyInjectionMode Mode They Keep two automated test windows 1.Selenium 2.Your Application

25 ProxyInjectionMode They eliminate the separate Selenium window, in favor of "injecting" Selenium into every HTML page By injecting ourselves into the HTML, They have increased control over our application To use PI mode, you need to start the Selenium Server with a special command line argument, like this java -jar selenium-server.jar –proxyInjectionMode cmd=getNewBrowserSession&1=*pifirefox&2=

26 Test Application in IE Two way to Test Application in IE Directly click on .hta file Through PHPUnit Elevated Security Privilege The two experimental "elevated security privilege" browser launchers are: *iehta: Launches Internet Explorer as an HTML Application (HTA). *chrome: Launches Firefox using a chrome URL.

27 Test IE Application with PHPUnit
CASE I: If Selenium Server is in Proxy InjectionMode Start server in Proxy Injection Mode Run Selenium IDE and record step with firefox Go to OptionsFormatPHP-selenium RC Copy that PHP code and paste in PHPUnit Folder PHPUnit will be in C:\Program Files\xampp\php\pear\PHPUnit Make xyz.php file (you could give different Name) Open that PHP file and change following line from $this-Selenium= new Testing_Selenium (“*firefox”, to $this-Selenium= new Testing_Selenium(“*iexplore”, Now type command phpunit xyz.php It will open IE browser for you and Test the application

28 CASE II: If Selenium Server isn’t in Proxy InjectionMode
Start server in Proxy Injection Mode Run Selenium IDE and record step with firefox Go to OptionsFormatPHP-selenium RC Copy that PHP code and paste in PHPUnit Folder PHPUnit will be in C:\Program Files\xampp\php\pear\PHPUnit Make xyz.php file (you could give different Name) Open that PHP file and change following line from $this-Selenium= new Testing_Selenium (“*firefox”, to $this-Selenium= new Testing_Selenium(“*iehta”,

29 DATA-Driven Code to Fetch Data from Excel Sheet
//code added by Niranjan $arr=array(1=>'a','b','c','d','e'); $filename = "c:\Info1.xls"; $sheet1 = "sheet1"; $excel_app = new COM("Excel.application") or Die ("Did not connect"); $Workbook = $excel_app->Workbooks->Open($filename) or Die("Did not open $filename $Workbook"); $Worksheet = $Workbook->Worksheets($sheet1); $Worksheet->activate; //$excel_cell = $Worksheet->Range("A1"); $excel_cell->activate; for($i=1; $i<5;$i++) { for($j=1; $j<5;$j++) $excel_cell = $Worksheet->Range($arr[$i].$j); print "The value is $arr[$i].$j => \n" .$excel_cell->value; }

30 QMetry- Live Example Add User into Qmetry-UPM module without Repository Add User with Repository

31 Question !!!

32 For more Information about Selenium Use my following Blog Address Thank You Niranjan Limbachiya


Download ppt "Testing With Selenium - Open source Test Automation Tool"

Similar presentations


Ads by Google