Selenium
-
Upload
shrialinda -
Category
Technology
-
view
13.843 -
download
0
description
Transcript of Selenium
InfoStretch Corporation - Company Confidential
Testing With Selenium - Open source Test Automation Tool
InfoStretch Corporation - Company Confidential
Agenda
Selenium OriginWhat is Selenium?Platform and Browser compatibilitySelenium IDEHow to work with Selenium IDE?Selenium COREHow to work with Selenium IDE?Testing Application with IDE/CORE?Selenium-RCWay to Test Application in IE Test IE application with PHPUnitDATA-DrivenQMetry- Live Example
2
InfoStretch Corporation - Company Confidential
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.
3
InfoStretch Corporation - Company Confidential
What is Selenium and whats it for?
4
Selenium tests run directly in a browser, just as real users do A java Script BasedOpen SourceWeb Testing ToolThat Support web 2.0 ApplicationOn Multiple BrowserAnd multiple OS
No other test tool covers such a wide array of
platforms
InfoStretch Corporation - Company Confidential
Contd..
Selenium is not meant for unit testingIts used for Functional or system TestingBut Not for Performance Testing
InfoStretch Corporation - Company Confidential
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+ Firefox 0.8 to 1.5 Camino 1.0a1 Mozilla Suite 1.6+, 1.7+ Seamonkey 1.0
Linux: Firefox 0.8 to 1.5 Mozilla Suite 1.6+, 1.7+ Konqueror
6
InfoStretch Corporation - Company Confidential
Introduction
Selenium
IDE CORE RC
Record Mode Bot Mode: HTML tables Driven Mode. Test Case in different Language
InfoStretch Corporation - Company Confidential
Selenium IDE
Selenium IDE is an integrated development environment for Selenium testsIt is implemented as a Firefox extension. (Note no IE Extension Available)It allows us to record, edit, and debug testsSelenium 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 IDEYou can choose to use its recording capability, or you may edit your scripts by hand
InfoStretch Corporation - Company Confidential
How to Start work with Selenium IDE?
Download from http://www.openqa.org/selenium-ide/download.action
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:
InfoStretch Corporation - Company Confidential
Contd..
Open firefoxfrom the menu: Tools ->Add-ons--> Extensionsnow drag-n-drop the xpi file to the extensions windowrestart firefoxYou 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)
InfoStretch Corporation - Company Confidential
IDE
InfoStretch Corporation - Company Confidential
Features:
Easy record and playbackDebug and set breakpointsAutocomplete for all common Selenium commands Save tests as HTML, PHP scripts, or any other formatSupport for Selenium user-extensions.js fileOption to automatically assert the title of every page
InfoStretch Corporation - Company Confidential
Selenium-CORE
Selenium core is a test tool for web
For Web application
Selenium core tests run directly
In a browserJust as real users do !!
Written in Pure JAVAScript
AndDHTML
InfoStretch Corporation - Company Confidential
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.
InfoStretch Corporation - Company Confidential
InfoStretch Corporation - Company Confidential
Live Example
Testing Google/QMetry Application with IDE and Core
InfoStretch Corporation - Company Confidential
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.
InfoStretch Corporation - Company Confidential
Selenium RC
Allow us to write automated web application in any programming language (Java, .NET, Perl, Python, Ruby, PHP)
Selenium Remote Control provides a Selenium Server, which cans automatically start/stop/control, any supported browser
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.
InfoStretch Corporation - Company Confidential
RC Architecture
InfoStretch Corporation - Company Confidential
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 –versionOnce 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
InfoStretch Corporation - Company Confidential
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=http://www.yahoo.com)
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
InfoStretch Corporation - Company Confidential
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, 260113 on session 260113
InfoStretch Corporation - Company Confidential
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
InfoStretch Corporation - Company Confidential
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
InfoStretch Corporation - Company Confidential
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 –proxyInjectionModecmd=getNewBrowserSession&1=*pifirefox&2=http://www.google.com
InfoStretch Corporation - Company Confidential
Test Application in IE
Two way to Test Application in IEDirectly click on .hta fileThrough PHPUnit
Elevated Security PrivilegeThe two experimental "elevated security privilege" browser launchers are:*iehta: Launches Internet Explorer as an HTML Application (HTA). *chrome: Launches Firefox using a chrome URL.
InfoStretch Corporation - Company Confidential
Test IE Application with PHPUnit
CASE I: If Selenium Server is in Proxy InjectionMode Start server in Proxy Injection ModeRun Selenium IDE and record step with firefoxGo to OptionsFormatPHP-selenium RCCopy that PHP code and paste in PHPUnit FolderPHPUnit will be in C:\Program Files\xampp\php\pear\PHPUnitMake xyz.php file (you could give different Name)Open that PHP file and change following line from $this-Selenium= new Testing_Selenium (“*firefox”,http://localhost:4444/);to $this-Selenium= new Testing_Selenium(“*iexplore”,http://localhost:4444/); Now type command phpunit xyz.php It will open IE browser for you and Test the application
InfoStretch Corporation - Company Confidential
CASE II: If Selenium Server isn’t in Proxy InjectionMode
Start server in Proxy Injection ModeRun Selenium IDE and record step with firefoxGo to OptionsFormatPHP-selenium RCCopy that PHP code and paste in PHPUnit FolderPHPUnit will be in C:\Program Files\xampp\php\pear\PHPUnitMake xyz.php file (you could give different Name)Open that PHP file and change following line from $this-Selenium= new Testing_Selenium (“*firefox”,http://localhost:4444/);to $this-Selenium= new Testing_Selenium(“*iehta”,http://localhost:4444/);
InfoStretch Corporation - Company Confidential
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;}}
InfoStretch Corporation - Company Confidential
QMetry- Live Example
Add User into Qmetry-UPM module without RepositoryAdd User with Repository
InfoStretch Corporation - Company Confidential
Question !!!
InfoStretch Corporation - Company Confidential
www.openqa.org/seleniumwww.nealford.comFor more Information about Selenium Use my following Blog Address
http://seleniumtest.wordpress.com
Thank YouNiranjan [email protected]