Saturday, September 17, 2011

Selenium vs TestNG vs Junit

Selenium vs TestNG vs Junit

People from QTP background or testers with no programming knowledge get confused with the above terms.

Selenium: What is Selenium? It is a program that can recognize objects on the browser, it is a browser automation tool similar to QTP. QTP is an exe file, where you install the program and is packaged with checkpoints and reporting tools. Where as selenium is a set of libraries that are required to compile and execute  the code, it is not an exe file can't be installed like a windows program. There are separate set of libraries for each language.

Selenium1.0 vs Selenium2.0 (Web Driver)

QTP vs Selenium

TestNG: It is a testing framework designed for different testing needs, unit testing, integration testing etc. As Selenium don't have assertions(Checkpoints), data driven testing and reporting facility, we need to implement these frameworks along with the selenium. It had different annotations, where you can group the selenium code into test cases and add assertions(Check points) that determine whether test case is pass/fail. It generate HTML reports at the end of test  and data providers used for data driven testing...many more features. It is also a set of libraries that are required to compile or execute the code. All these libraries are added to your project in Eclipse IDE or ANT during  execution.

JUnit: It is also a testing framework similar to TestNG.

TestNG vs JUnit

---

Wednesday, August 31, 2011

Selenium1.0 - Handle Pop-Up and Alerts


Selenium1.0 - Handle Pop-Up and Alerts

As per my understanding Pop-Ups are classified into four types.

1. JavaScript alerts: By default Selenium suppress the alerts during test execution, so not visible on the browser. If the alerts are not handled properly Selenium through following exception "com.thoughtworks.selenium.SeleniumException: ERROR: There was an unexpected Confirmation! [Do you want to Continue?]". This alert is further classified into "ok" , "ok and cancel" alert. This alert can be handled in the following way.

assertEquals("Saved Sucessfully!", s.getAlert()); // After click

s.chooseOkOnNextConfirmation(); // Before Click

s.chooseCancelOnNextConfirmation(); // Before Click

s.getConfirmation(); // After click

For "ok and cancel" alert, you need to consume the alert with "s.getConfirmation();" other wise it will   display the exception saying "ERROR: There was an unexpected Confirmation!". Basically you should be using two statements: (ok/cancel)conformation before the click and consume after the click.

If you insert an alert statement when there is no alert on the web page, selenium will display following exception - com.thoughtworks.selenium.SeleniumException: ERROR: There were no alerts

2. HTML Pop-Ups using JQuery or other techniques : Here popup is constructed using div and is visible on the screen. This can be handled in the following way

s.click("popup_ok")

s.click("popup_cancel")

3. Windows Pop-Ups : These are windows based popup and is visible on the screen. Selenium is not capable to handle this kind of pop-up, need to use AutoItv3. To handle this pop-up record the script in AutoItv3, convert into exe format and then call from Java program.

Runtime.getRuntime().exec("C:\\OKbtn.exe ");


WinWaitActive("#32770", "Message from webpage",10)

WinFlash("Message from webpage","", 4, 500) ; Just to Flash the window

ControlClick("Message from webpage", "","[CLASS:Button; INSTANCE:1]");


For more information about AutoItV3 read this Post.

4. Model pop-ups


http://bharath-marrivada.blogspot.com/2010/12/selenium-simulate-modal-dialog-pop-up.html


---

Thursday, July 28, 2011

How To Setup - Selenium 1.0, JDK, TestNG, ANT

How To Setup - Selenium 1.0, JDK, TestNG, ANT

Selenium setup checklist
1. JDK
2. ANT
3. Eclipse IDE
4. Eclipse TestNG
5. Selenium
6. How to start Selenium server
7. How to create selenium project in Eclipse IDE
8. How to execute code in eclipse IDE using TestNG

Select following link to for Selenium full-fledged implementation.

Note: You need to have admin privileges to install few software's.

1. JDK

Download from http://www.oracle.com/technetwork/java/javase/downloads/index.html



JDK is machine and OS dependent, Check whether your machine is 32 OR 64 Bit.
How to Check?
Programs -> Accessories -> System Tools -> System Information

Download your corresponding JRE file and install on your PC.


Check whether it is installed correctly?
Type java  -version at the command prompt, you should see the version related info.

2. ANT


It is a self installable exe file, located the java JDK directory during installation. 
Logoff and login for complete installation.
Check whether it is installed correctly?
Type ant  - version at the command prompt, you should see the version related info.

3. Eclipse IDE


It is not required to install this software, just run the exe file to open the editor.

4. Eclipse TestNG

Inside the eclipse, select   Help - > Eclipse Market Place
Search for TestNG and install directly into IDE.



5. Selenium



Unzip the file and copy Selenium Server and Selenium Java client driver FOLDERS separately for later use.



6. How to start Selenium server

In the "Selenium server" folder as mentioned above, you can find “selenium-server.jar”.
Place this file in new folder "SeleniumServer", from the command prompt opens this folder path and run following command.
Java  –jar selenium-server.jar
You will see following screen, don’t close the window (Keep it the window open)


If you see any errors, something gone wrong with the server. 

7. How to create selenium project in Eclipse IDE


Open the Eclipse IDE by selecting eclipse.exe file.
Select File->New -> Java Project


Enter project name and hit “Next”




Select “Finish”
Now you will see the project name "MyFirstProject"  in the “Package Explorer” window.
Right click on the project name and create “Package”


Click on finish after typing the package name "Selenium".


In the package explorer, right click on the package name “Selenium” and select “Configure Build Path”.



Add following JAR files showed in the below screen by selecting “Add external jar” button.
You will not be able to run your test without these files, try locating it and add those files shown in the below screen.



Now, right click on the package "Selenium" and select class


Enter class name “Test” and select Finish.



You will notice a new class is created in the package explorer.
In the same way create classes as per your requirement and place necessary code.

8. How to execute code in eclipse IDE using TestNG

Copy the code from the below link and execute the test.
http://bharath-marrivada.blogspot.com/2011/07/selenium-testng-parameterization-excel.html


If you still see any errors on the screen, place the cursor over the error code, Eclipse IDE provide auto suggestion on how to resolve the issue.


---

Wednesday, July 6, 2011

Selenium - TestNG Parameterization

Selenium - TestNG Parameterization

Based on the testing requirement you many need to repeat the test with multiple data sets.
In this post I will explain how to achieve this (parameterization) using TestNG.

There are two ways of sending parameters to the selenium test
(1)using testng.xml
(2) Programmatically
    i)array of objects (Object[][])
    ii)Iterator

Note: I have purposefully commented selenium code for better understanding of TestNG Parameterization.

Using testng.xml 
How to execute the test with Eclipse, select this link.
How to execute the test with Ant, select this link.
Selenium TestNG, Select this link.

Below sample code will help you understand how to send parameters from testng.xml.
Testng code


  
  
  
    
     
   
   
     
        
        
     
   
 


Java code
package package1;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import com.thoughtworks.selenium.*;

public class Sample 
{
    //public Selenium s = new ds( "localhost",4444,"*iexplore","www.test.com");
    //private Selenium s = new ds( "localhost",4444,"*firefox",BASE_URL);
    @BeforeClass (alwaysRun=true)
    protected void setUp()throws Exception
    {
     /*
     s.start();
     s.windowFocus();
     s.windowMaximize();
     s.windowFocus();
     */
    }
    @AfterClass(alwaysRun=true)
    protected void tearDown() throws Exception
    {
     //s.stop(); 
    }
    @Parameters({"UserNameTestng","PasswordTestng"})
    @Test(groups={"test","SampleDemo"},enabled=true)
    public void test_verifyData1(String s1,String s2) {
     System.out.println(s1+" -  "+s2);
    }    
}



Select following option while executing the code from eclipse (Look at the screen shot)

Output for the above code (Look at the below screen shot)


Using this method we can pass the parameters using xml file, but we can't achieve repeatability, executing the same test with different data sets.

 Programmatically


i)array of objects (Object[][])
If  you have data set, it is possible to place all the values in @dataprovider and run the program.
Dimension one is considered as number of rows, dimension two is considered as number of different data set columns. It will automatically repeat the execution of same code as per the object dimension one count.
Below sample code will help you understand the concept in a better way.

Java Code
package package1;


import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import com.thoughtworks.selenium.*;

public class Sample 
{
    //public Selenium s = new ds( "localhost",4444,"*iexplore","www.test.com");
    //private Selenium selenium = new DefaultSelenium( "localhost",4444,"*firefox",BASE_URL);
    @BeforeClass (alwaysRun=true)
    protected void setUp()throws Exception
    {
     /*
     s.start();
     s.windowFocus();
     s.windowMaximize();
     s.windowFocus();
     */
    }
    @AfterClass(alwaysRun=true)
    protected void tearDown() throws Exception
    {
     //s.stop(); 
    }
    
   @DataProvider (name="TestData") 
   public Object[][] createData1() {
   return new Object[][] {
     { "Bharath", "11" },
     { "Raj", "22"},
       };
    }
        
        
    @Test(dataProvider = "TestData",groups={"test","SampleDemo"},enabled=true)
    public void test_verifyData1(String s1,String s2) {
        System.out.println(s1+" - "+s2);
    }    
       
}

Output for the above code (Look at the below screen shot)

This method will be useful when you have the data set upfront, What is the situation if the data exist in excel or notepad (csv format).

ii)Iterator
If the data exist in excel or notepad, this technique is the best choice. Below sample code will help you understand the concept in a better way. I have used Jexcel api to read data from the excel file, don't forget to add jxl.jar to package build path.Basically I am reading the data from the excel file and feeding it to the iterator object.


Java Code
package package1;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import com.thoughtworks.selenium.*;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;


import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;


public class Sample 
{
    //public Selenium s = new ds( "localhost",4444,"*iexplore","www.test.com");
    //private Selenium selenium = new DefaultSelenium( "localhost",4444,"*firefox",BASE_URL);
    @BeforeClass (alwaysRun=true)
    protected void setUp()throws Exception
    {
     /*
     s.start();
     s.windowFocus();
     s.windowMaximize();
     s.windowFocus();
     */
    }
    @AfterClass(alwaysRun=true)
    protected void tearDown() throws Exception
    {
     //s.stop(); 
    }
 @DataProvider (name="TestData") 
 public Iterator createData() throws IOException{                 
 ArrayList myEntries = new ArrayList();  
 File inputWorkbook = new File("c:/jexcel.xls");   
              Workbook w;     
 String Temp1, Temp2;       
 try {         
  w = Workbook.getWorkbook(inputWorkbook);     
  Sheet sheet = w.getSheet(0);       
  for (int i = 0; i < sheet.getRows(); i++) {      
                // column, row     
  Cell cell = sheet.getCell(0, i);         
  Temp1 = cell.getContents();                 
  cell = sheet.getCell(1, i);      
  Temp2 = cell.getContents();                
  myEntries.add(new Object [] {Temp1,Temp2});       
   }      
  } 
  catch (BiffException e) 
  {e.printStackTrace();}      
  System.out.println("Successfully read data file");          
                return myEntries.iterator();          
 }    
  
 @Test(dataProvider = "TestData",groups={"test","SampleDemo"},enabled=true)    
 public void test_verifyData1(String n1,String n2) {    
  System.out.println(n1+" "+n2); }        
}
Sample excel file shown below. Always save in .xls only, as jxl currently support .xls.
Output for the above code (Look at the below screen shot)
How to place data provider in different class?
By default it will search for dataprovider in the current test class. If you want to declare the data provider in different class, specify the method as static and mention the class name in the DataProviderClass attribute.
@Test(dataProvider = "TestData",dataProviderClass="StaticData.class",groups={"test","SampleDemo"},enabled=true)
---

Saturday, June 4, 2011

QTP vs Selenium 1.0

QTP vs Selenium 1.0

1. Licence type
QTP - Commercial software (Concurrent and per user licence)
Selenium - Open source.

2. Software size
QTP - Around 1.5GB
Selenium - Set of Libraries, around 20MB (Need to include other supporting software)

3. Software Support
QTP - From HP
Selenium - Saucelabs.com, Element34 , Commercial Support

4. Identifying objects.
QTP -  Object properties, Repository objects
Selenium - Object properties, xPath, CSS, DOM

5. Spying object
QTP - GUI Spy
Selenium - There is no option, can record script in Selenium IDE, can spy objects using IE developer tool bar, FireBug and also using http://saucelabs.com/builder

6. Scripting language
QTP - VB Script
Selenium - Any language HTTP library (Java, C#, Python, Ruby...)

7. Environment.
QTP - Windows
Selenium - Windows, OS X, Linux, Solaris...

8. Browsers supported
QTP - IE, Firefox (Run scripts)
Selenium - IE, Firefox, Safari, Opera (selenium 2: Chrome, Android, iPhone)

9. Architecture
QTP - Not known, It makes tight integration with IE browser using Windows API's.
Selenium - It can be written in any language that support HTTP library, corresponding language bindings are sent to Selenium RC designed on Jetty, RC launch the browser by injecting the "BrowserBot" JavaScript into the browser. Screen operation are performed by the "BrowserBot" by communicating with RC using XMLHttp request.

10. Limitations (I mean automation is not possible)
QTP -  As per my understanding nil (I don't want to mention about the Number precision, Text length...)
Selenium - File upload/download, Model dialog ... How to over come these limitations select links?

11. Mapping objects
QTP - Browser.Page.Object.Method for each step.
Selenium - Directly execute methods.
bindu
12. Debugging code
QTP - Yes
Selenium - No

13. Control Opened browsers
QTP - Yes (Opened after QTP program)
Selenium - No (Session information is lost) QTP, Selenium interact with the browser differently.

14. Supporting Applications
QTP - Web applications, SAP, Activex, VB, Windows...(Support provided using Addins)
Selenium - Only Web application.

15. As performance testing tool
QTP - No, you can run one QTP application in one CPU.
Selenium - It can open many many browsers using GRID, many companies line PushToTest, BrowserMob, Gomez use selenium technology for running load test.

16. Current Version
QTP - 11
Selenium - 1.0 (2.0 in Beta) Selenium 1.0 vs Selenium 2.0

17. Object not found
QTP - It will wait till the timeout happen.
Selenium - If browser status is Done, it will through exception. In some cases it will wait for time out. I did like this feature.

18. Execute JavaScript
QTP - No (Not required, you can get entire page info directly from QTP)
Selenium - Yes

19. Access page DOM
QTP - Yes
Selenium - Yes

20. Flex objects
QTP - Yes
Selenium - Yes  Selenium Flex

21. Scripting complexity
QTP - Simple, easy to access the file system, Excel. But programming knowledge.
Selenium - Complex. Need to understand Java class, interface and testing framework. Need to know following items for full fledge implementation. You are getting it free entirely, can't you put extra efforts?

22. Cost
QTP - 9K USD per user (Approx) + Annual maintenance charges.
Selenium - FREE (Any number of users...)

23. IDE
QTP - Own IDE
Selenium - Any IDE (I prefer Eclipse)

24. Flavors
QTP - Just QTP
Selenium - Selenium core, Selenium IDE, Selenium RC, Selenium GRID, Selenium 2.0 (Webdriver)

25. Extendability
QTP - No
Selenium - Yes, you can customize and implement for new browsers.

26. Exception Handling
QTP - Need to handle manually. Using .Exist, On error resume next, recovery scenarios. Script would stop in the middle by throwing run-time error if not handled properly.
Selenium - Handled automatically when used with TestNG, it will automatically move to next test case.

27. Reporting and Assertions(Checkpoints)
QTP - Reporting and checkpoints are built in the same package.
Selenium - Need to depend on testing frameworks like TestNG or Junit.

Your Choice Now ?


---


Selenium - Keyword Driven Framework

Selenium - Keyword Driven Framework.

Webdriver - Keyword driven framework using page objects

Having experience in implementing Hybrid framework in QTP, Initially I started converting this existing QTP framework into Selenium framework. Following are my challenges

1. Most of the user test data is stored in the MS excel files, there are open source APIs that can connect to excel files, but I had lot of issues reading and writing data continuously.
2. Test case PASS/FAIL status and summary report creation had custom logic as per the requirement.

As I didn't have enough time to over come above challenges currently, I have taken alternative approach.

I have extended the Selenium interface and written all user methods in that, so that I can create a clean test class. TestNG framework is taking care of test execution summary.

Note: Need to extend all the existing methods before adding new methods.
My intention is to hide the object locater information and user Keyword appear in the auto suggest list(Auto complete) in IDE environment.

Attaching the test class screen shot, where locator information is hidden in the interface methods.

Attaching Eclipse IDE screen shot where user methods are displayed in auto suggest drop down.



Attaching User method screen shot.



--

Monday, May 30, 2011

Selenium Assertions - Assert Vs Verify(Soft Assertions) Vs WaitFor

Selenium Assertions - Assert Vs Verify(Soft Assertions) Vs WaitFor

All Selenium Assertions can be used in 3 modes: "assert", "verify", and "waitFor".

When an "assert" fails, the test is aborted.

When a "verify"(Soft Assertions)  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. You don't have this facility in Selenium RC. You can implement the same using TestNG framework, select this link for custom TestNG code implemented using listeners.

"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 (setTimeout).

---

Sunday, May 1, 2011

VB Script - Edit xml document.

VB Script - Edit xml document.

Recently I was performing a load test on Web service that consume XML document. The load test parameters are: upload 2000 XML files sequentially having different ID's (XML document contain  "PayloadID" and "OrderID" that should be unique). In order to create 2000 XML files with unique id's I have created following VB script.
  
Path = "C:\Documents and Settings\bharathm\Desktop\"
xmlfile=Path & "orginal.xml"    'your source file name
NumberOfFiles = 2
AppendString = "B"

set oparser=createobject("msxml2.domdocument")
with oparser
    .async=false
    .validateOnParse=false
    .resolveExternals=false
    .load xmlfile
end with
    
if oparser.parseerror.errorcode<>0 then
    wscript.echo "xml file " & xmlfile & " is not well-formed." & vbcrlf & "Operation aborted."
    wscript.quit 999
end if

for count = 1 to NumberOfFiles
 value = AppendString & count 'Unique string to update document
 set oroot=oparser.documentElement
 oroot.setAttribute "payloadID", value
 Set currNode = oparser.documentelement.selectSingleNode("//cXML/Request/OrderRequest/OrderRequestHeader")
 currNode.setAttribute "orderID",value
 outfile=Path & "TestFiles\" & value &".xml"   'create new output file with unique name
 oparser.save outfile
next
    
set oparser=nothing 
wscript.echo "Completed"

I hope this post will help you in manipulating XML document and make duplicate copies.

---

Friday, April 15, 2011

Why Load Testing from the Cloud Doesn't Work

Thursday, April 7, 2011

Selenium - Capture Screenshot using TestNG

Selenium - Capture Screenshot using TestNG

It is always a best practice to capture a screen shot on error, so that we can easily analyze the issue.
With prior experience on Hybrid Framework using QTP, I have considered following points while creating the Screen capture logic.

1. Reduce the screen capture code redundancy.
As we write test in different methods, in-order to capture the screen shot on error, we need to wrap every test method in the following way
try { 
// test here
    } catch (Throwable e) { 
      // capture screenshot here
    }
How to over come this redundancy?
TestNG provide Listeners and Reporters through which we can generate custom reports.
In this example I am extending TestListenerAdapter, which implements ITestListener with empty methods, so that I don't have to override other methods of the interface that I am not interested.
I have decided to use onTestFailure method to capture the screen shot as it is invoked once test fails.

2. File naming convention
It is better to name the file using time stamp, so that we can easily understand when this error occurred.
Apart from this I also append the file name with IP address that can help me in identifying on which system this error occurred, assuming you are working on different browser combinations from different locations.

26_Mar_2011__02_51_33PM_171.22.0.111.png

3. Where to store the file
Store all the files in separate folder inside the working directory. I use separate folder called "ScreenShots".

C:\eclipse\MyWorkSpace\Implements23\ScreenShots\26_Mar_2011__02_51_33PM_132.22.0.111.png

4. How to view the files
I am directly inserting the file names in the test reporter, so that screen shot appear as hyper link.


5. Image file format
I prefer using PNG format.

Following is the code written using above mentioned points.

Note: I am not using "selenium.capturescreeshot" method, using custom logic to capture screenshot which I feel is easy. This will work even without selenium. I am using Selenium interface, didn't find way to refer the selenium object in the TestNG listeners.

package package1;

import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.*;
import org.testng.TestListenerAdapter;
import java.io.*;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.lang.*;
import java.net.*;

public class TestNGCustom extends TestListenerAdapter {
private int Count = 0;

//Take screen shot only for failed test case
@Override
public void onTestFailure(ITestResult tr) {
ScreenShot();
}

@Override
public void onTestSkipped(ITestResult tr) {
//ScreenShot();
}

@Override
public void onTestSuccess(ITestResult tr) {
//ScreenShot();
}

private void ScreenShot() {
try {

String NewFileNamePath;

/*
//Code to get screen resolution
//Get the default toolkit
Toolkit toolkit = Toolkit.getDefaultToolkit();
//Get the current screen size
Dimension scrnsize = toolkit.getScreenSize();
//Print the screen size
System.out.println ("Screen size : " + scrnsize);
*/    

//Get the dir path
File directory = new File (".");
//System.out.println(directory.getCanonicalPath()); 

//get current date time with Date() to create unique file name
DateFormat dateFormat = new SimpleDateFormat("dd_MMM_yyyy__hh_mm_ssaa");
//get current date time with Date()
Date date = new Date();
//System.out.println(dateFormat.format(date));

//To identify the system
InetAddress ownIP=InetAddress.getLocalHost();
//System.out.println("IP of my system is := "+ownIP.getHostAddress()); 

NewFileNamePath = directory.getCanonicalPath()+ "\\ScreenShots\\"+ dateFormat.format(date)+"_"+ownIP.getHostAddress()+ ".png";
System.out.println(NewFileNamePath);

//Capture the screen shot of the area of the screen defined by the rectangle
Robot robot = new Robot();
BufferedImage bi=robot.createScreenCapture(new Rectangle(1280,1024));
ImageIO.write(bi, "png", new File(NewFileNamePath));
Count++;//Assign each screen shot a number
NewFileNamePath = "ScreenShot"+ Count + "";
//Place the reference in TestNG web report 
Reporter.log(NewFileNamePath);


} 
catch (AWTException e) {
e.printStackTrace();
} 
catch (IOException e) {
e.printStackTrace();
}
}
}


Important Notice: When you implement TestNG interfaces, you need to inform about the listeners very early in the process, otherwise it will ignore your implemented interfaces. Following are the ways

Using -listener on the command line.
Using with ant.
Using in your testng.xml file.
Using the @Listeners annotation on any of your test classes.

I prefer using at test calass, attaching the screen shot for more clarity.

For more information refer TestNG documentation.

How to handle black/empty screen shots

Enjoy taking screen shots in Java...

Download the entire working code that is implemented in a project from the below link.

SeleniumWebdriver - Page objects Implementation - Part 2

---

Friday, March 18, 2011

Gomez Vs NeoLoad Vs Loadrunner Vs Selenium

Gomez Vs NeoLoad Vs Loadrunner Vs Selenium

One of my friend asked me for the comparison between Gomez and NeoLoad. I have included Loadrunner Ajax(Click&Script) protocol, as it is a well known performance testing tool. There is separate post for NeoLoad Vs Loadrunner. Also included Selenium function testing tool in the comparison because it can be used as performance testing tool and Gomez use Selenium scripts to run functional tests. HP QTP can't run parallel and Cross-Browser tests, so it is not included in the comparison.

Before starting the comparison, lets understand the performance issues between Server and Browser with few images, so that you can choose the tool in a better way.

Things can go wrong in any of the below mentioned places, Is your tool capable of identifying it.


Below are the issues at the application level. Below screen shot is taken from dynaTrace, excellent core application performance monitoring tool.


Currently there is no single browser dominating the web, every browser has its own share. You have full control of your data center, what about data coming from the third party sites. Today's websites are complex amalgamation of own and third party services. On a average browser need to resolve 8.3 different hosts (Different IP address) to display the content. Attaching the screen shot for more clarity.


Why will this impact the performance? Every browser has its own JavaScript engine, so the page rendering happen differently and have different parallel downloads. Website that work for one browser may not work properly with other browser at the some locations due to issues in third party services, If you can't detect it, you will loose the business. For more understanding select this link. Read this post to understand the rendering differences between FF and IE.



Small Description
Gomez is a portal where user can conduct Performance tests(Any browser/OS, Mobile devices), Cross Browser tests, monitor networks  and functional tests without any hardware requirements. Entire execution happen at Gomez servers.


NeoLoad is a pure performance testing tool that record and replay HTTP(S) requests.

HP Loadrunner is a pure performance testing tool which support different protocols.

Selenium is an open source tool that is designed to conduct functional testing, but by using Selenium GRID we can run parallel tests in different browser environments.

Licence Cost
Gomez - SaaS model.
NeoLoad - Number of virtual users, technology and monitoring services.
Loadrunner - Number of Virtual users and Protocol bundles.
Selenium - Free

About The Software
Gomez - It has Gomez screen recorder(GSR), once you record the script and make necessary dynamic value changes, you can upload into GPN(Gomez Performance Network) portal. You can access this site online and conduct tests, view results.
NeoLoad - Around 160MB software that is written in Java need to be installed on your workstations. If you are generating more load, need to install separate LoadGenerator software on separate server. Also LoadGenerators can be deployed from the cloud.
Loadrunner - Around 2.5GB software that has separate applications for recording, test execution and analysis. Also has cloud support.
Selenium - Need to have Java and set of Selenium libraries that can be executed using any language that support HTTP library (Java/.Net/Python/Ruby...)

Script Recorder
Gomez - All the user clicks or actions are recorded, once user select an item on the screen, system automatically generate JavaScript associated with that click (document.GetElementByID("LoginBtn")), use Firefox engine to record the script. There are different actions available Navigate, Type, Wait, Form Fill....... It can identify the screen objects using DOM or CSS. There are different built in Gomez functions that can provide data and reference to different elements. You have got the option to use User clicks OR directly POST the form. During replay, user action associate JavaScript get executed in the Gomez injected JavaScript core inside the browser.

NeoLoad - No user clicks are recorded, It record Request/Response during form submit. During replay, it re-executes the requests that re recorded after changing the dynamic values.
Loadrunner - Ajax(Click&Script) protocol is suitable for WEB2.0 applications, this protocol has HP QTP technology with limited object properties. User clicks are recorded as C functions.
web_click("ctl00$RightContent$ddlCycleNo",
"Snapshot=t14.inf",
DESCRIPTION,
"Name=ctl00$RightContent$ddlCycleNo",
"id=ctl00_RightContent_ddlCycleNo",
"FrameName=contentFRAME",
ACTION,
"Select=B",
LAST); 

It records only in IE, I think these c functions are converted into JavaScript to execute on the Loadrunner browser. 
The same functions are executed during replay in Loadrunner proprietary browser.
Selenium - It has Selenium IDE that record and replay script as Firefox add-on. Also you can directly write script in any of the following languages(Java/.Net/Python/Ruby...)
Selenium - For sample code select this link.

Script Replay 
Gomez - It replay the script in real and Gomez browser so there is page rendering.
Neoload - No browser, just replay of HTTP(S) requests.
Loadrunner - It replay the script in Loadrunner proprietary browser so there is page rendering. Lot of issues when page contain other objects.
Selenium - It replay the script in real browser so there is page rendering.

LoadGenerators
Gomez - It network exist in 168+ countries and 2,500+ ISP's. It consist of 500+ combinations of browsers and OS, 150+ commercial data centers, 5,000+ mobile supported devices and 1,50,000+ commercial grade desktops through which it is possible to generate enormous real user load.
Backbone are servers deployed on cloud to generate massive load.
Last Mile systems acts like a real users, executing single test by residing on real network, devise(Browser OR Mobile) and location. With massive last mile systems deployed around the word, it would be difficult for any one to challenge Gomez Network


NeoLoad - Deployed in the premises or on the cloud. Load getting generated from few places only.
Loadrunner -  Same as above.
Selenium - There is no concept of Loadgenerators in selenium, using GRID we can run multiple browsers on different systems.

WAN Emulators
What are WAN emulators?
Gomez - It is not required, as tests are getting executed on real network, device and location.
NeoLoad - There is no facility to add network effects, just limit bandwidth.
Loadrunner - It has integration with  SHUNRA Virtual Enterprise Suite to generate network effects.
Selenium -  There is no facility to add network effects.

Multi-Browser support
Gomez -  It support Firefox, IE and Gomez proprietary agent.  Also it consist of 500+ combinations of browsers and OS...Amazing, with "Reality View XF" where screen shots of different browsers are shown in a single page and compared against selected screen shot to find object devastation.
NeoLoad - It doesn't execute in a browser.
Loadrunner - No, it execute in Loadrunner propriety browser.
Selenium- Yes, you need to have own software and hardware. If you don't have consider SauceLabs.

Test execution length
Gomez - You can schedule your test and run for any amount of time. You have also got facility to stop collecting metrics during server maintenance, so that averages are not deviated. All the results are stored in the GPN.
NeoLoad - If you run the test for 4 days, I feel system would get stuck while processing the metrics.
Loadrunner - I think the same as NeoLoad
Selenium - You can schedule using Hudson-CI.

Response time and Test results
Gomez - It provide results in great detail. You can get based on Geography, ISP, Location, Browser type and even browser rendering details(Object level). Each browser JavaScript engine renders in different way, this will be helpful us understand the cross browser performance impacts at end user. It also has the capability to take the browser screen shot during error.

NeoLoad - Container and request level.
Loadrunner - Record at transaction level.
Selenium - There is no built in facility to calculate response time, need to consider other methods.

Functional Testing
Gomez - Can execute scripts created using Selenium IDE.
NeoLoad - No
Loadrunner - No
Selenium - It is a function testing tool with cross-browser and parallel test execution capability.

Mobile Platform Support
Gomez - Yes
NeoLoad - No
Loadrunner - No
Selenium - Yes

Resource Monitoring
Gomez - It monitors entire delivery chain, from server, ISP to the end user.
NeoLoad - Monitor the server resources and throughput.
Loadrunner - Same as above.
Selenium - No resource monitoring capability.

Flex Support
Gomez - Support Flex/Silver-light, I am not sure how they are able to select Flex objects. As Flex is proprietary tool doesn't expose the methods in the DOM, generally .swf file need to be compiled with extra libraries. This compilation happen on fly while data getting downloaded into the browser, but increases number of objects and response time.
NeoLoad - It convert Binay data into readable format and then convert back after changing dynamic values as it is recording at request/response level, which is different from other reorders.
Loadrunner - It support, But I had issues identifying the objects.
Selenium - Yes, Select this for more information.

Presentations and Whitepapers
Gomez - Awesome, I love to read those presentations.
NeoLoad - Only pertaining to the tool.
Loadrunner - Only pertaining to the tool.
Selenium - As it is a open source tool, some time getting proper information would be difficult.

How to Choose and Use
Gomez - If your application is being used across different location or geographies with different browser combinations and your application has CDN or other third party services. Gomez is the best solution. It is ultimate in performance testing.
NeoLoad - If want to test the application inside the firewall OR if your application is used in specific places, generate the load from Cloud. For calculating true response time,  execute Selenium test for each location with required browser combinations. It is not easy to generate enormous load using real browsers as they require lot of resources, the best combination would be generating part of the load using HTTP(S) request servers as they are very cheap and the remaining part from real browser combinations.
Loadrunner - Same as Neolaod, you can use HP QTP to calculate response time, If there are more browser combinations need to move to Selenium.
Selenium - User Selenium GRID or other vendors to generate load. Some companies link BrowserMobPushToTest use Selenium GRID to conduct performance testing.

KeyNote Systems is similar to Gomez.

---




Friday, March 4, 2011

NeoLoad 3.2 With Cloud Support


 New features
  • Cloud testing
  • Silverlight module
  • Siebel module
  • VMware monitoring
  • SOAP: support for WS-Security
Neotys has opened its online store! Purchase or lease your licenses online and receive them immediately.
NeoLoad realistically simulates users and analyzes your servers' behavior. Get operational with NeoLoad 3.2 quickly, thanks to its intuitive interface and its advanced wizards, and take advantage of its exclusive features to:
Test more quickly:
  • Automatic handling of all your application's parameters (without any scripts)
  • Preconfigured monitoring and threshold alerts for a quick analysis of your servers
  • Smart pinpointing of your applications' critical performance issues
Test more efficiently:
  • Detailed statistics in real time during test runs
  • Results and analysis by business transaction
  • JavaScript for further customizing scenarios
Test all your Web applications:
  • View the supported technologies (AJAX, SOAP, GWT, Adobe Flex, Silverlight, Oracle Forms, Siebel, ... )
  • View the monitoring modules (all mainstream operating systems, Web servers, application servers and database servers available on the market are supported)
  • Test from your internal lab or from the Cloud


---

Saturday, February 26, 2011

Selenium 1.0 vs Selenium 2.0 (Selenium Web-driver)

Selenium 1.0 vs Selenium 2.0 (Selenium Web-driver)

Selenium is browser automation tool, for more information select this link.
We already have Selenium1.0, why Selenium2.0?

Selenium1.0 can't tackle following items.
1. Native keyboard and mouse events.
2. Same origin policy XSS/HTPP(S)
3. Pop-ups, dialogs (Basic authentication, Self signed certificates and File upload/download)

Selenium2.0 has cleaner API, webdriver and webelements object, better abstraction.
//Web driver object
browser = webdriver.firefox()
//Web element object, to refer any object on the browser
search_box_google = browser.find_element_name('q')
Support of mobile devices- Android, iOS (Open web testing)
node.JS is server side JavaScript new programming language supported.
I have not seen Java Docs for Opera and Safari browsers.




Support for different types of mobile testing
1. Emulator.
2. Device connected to workstation.
3. Real device on real location on real network

Improved architecture.
Removing road blocks, hacks and workarounds
Scales up/down.
Selenium2 = Webdriver + Selenium1.0 (merging two different projects)


Lets understand the reason behind merging these two projects.

Selenium 1.0 - You can program in any language, but the prerequisite is that it should support HTTP library.  It initially started as bucket of JavaScript, later Selenium RC(Remote Control) was introduced. RC is a headless Java serer that acts as a proxy server to send commands to to the Selenium Core (JavaScript program that is running in the browser, set of functions). RC receives commands from the test program, interprets them, report back the results of those tests to the test program.  RC consist of Selenium core, that is inject into the browser using client library API when the test program opens the browser. Selenium core interprets the commands coming from the test program and execute selenese commands using browsers built-in JavaScript engine.

Selenium is the first open source browser based testing framework that quickly added support for new browsers as it is written in JavaScript.

Like any large project, Selenium is not perfect. As it is entirely written in JavaScript, which causes significant weakness. Every browser impose very strict security rules on the JavaScript being executed to protect the users from malicious scripts. This make testing harder for some scenarios. For example IE JavaScript security model don't allow to change the value of the INPUT file element for uploading the file and navigating between different domains (same origin policy) .
As it is a mature product, Selenium APIs has grown over time and it becomes harder to understand how best to use it.

Webdriver project was created by Simon Stewart, it is a clean and fast framework for browser testing automation. Webdriver take different approach for the problems faced by selenium (discussed above). Rather than being a JavaScript application used in the browser, it uses whichever mechanism is most appropriate to control the browser. IE - C++ mainly using automation APIs, Firefox - JavaScript in a XPCOM component (Add-in) ,Chrome - ???.
By changing the mechanism used to control the browser we can overcome the JavaScript security model. When these techniques are not sufficient, Webdiver can use facilities provided by operating System, especially when user want to simulate inputs from the Keyboard and mouse. By using these techniques we are trying to simulate how a real user interact with the browser.
Webdriver had Object Base API when compared with the Selenium which as Directory based approach.
Webdriver JAVA API looks like this.
// Create an instance of WebDriver backed by Firefox
WebDriver driver = new FirefoxDriver();

// Now go to the Google home page
driver.get("http://www.google.com");

// Find the search box, search for something
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("selenium");

// And now display the title of the page
System.out.println("Title: " + driver.getTitle());
When these two frameworks are compared side by side, weakness of one framework is addressed by other.
Webdriver support for multiple browsers require lot of effort from the framework developers, where as selenium can be easily extended. Selenium always require real browser, but it can make use of Webdriver HTML unit driver which is very fast and light weight browser that execute in the system memory. Selenium solve most of the common situations in an automation testing, but Webdriver ability to support out side the JavaScript sandbox provides more interesting possibilities. Webdriver don't support parallel testing, where as Selenium has answer by using Selenium GRID (new GRID 2.0 require selenium server). Although this would not solve the limitations of existing Selenium JavaScript, but it would become easier to test broad range of browsers.

Webdriver APIs are used for driving the browsers as per the user requirement, every browser has most natural language "Best Fit" for driving it, so that each developer can develop the driver independently.
But there is a problem, a fix made to one driver don't guarantee that the same fix will resolve the issue in other drivers. Every programmer is good in his own language, Java programmer many not be efficient in writing C++ programs, this create lot of redundant work across the drivers and huge testing activity.
Now the team came up with the concept of Atoms, they have decided to merge the common code across the drivers so that maintenance and development is easy. What will be the common code across all the drivers? Querying the state of browser to find an element and getting attribute values from the page DOM is the major effort across the drivers, the best common language across all the browsers for accessing DOM is by using JavaScript and this is what Selenium Core consist of. Instead of loading the single large JavaScript file into the browser and creating burden on the browser engine. They have decided to break the code into chunks(i.e Atoms), compress the JavaScript with other tools and load it on demand. These atoms are common across all the drivers.
IE browser use C++ as best fit language, how do they pass atoms(JavaScript) to it? I think by placing it in header files.

Following are the drivers available in Selenium2.0 currently
AndroidDriverChromeDriverEventFiringWebDriverFirefoxDriverHtmlUnitDriverInternetExplorerDriverIPhoneDriverIPhoneSimulatorDriverRemoteWebDriver

Name of driverAvailable on which OS?Class to instantiate
HtmlUnit DriverAllorg.openqa.selenium.htmlunit.HtmlUnitDriver
Firefox DriverAllorg.openqa.selenium.firefox.FirefoxDriver
Internet Explorer DriverWindowsorg.openqa.selenium.ie.InternetExplorerDriver
Chrome DriverAllorg.openqa.selenium.chrome.ChromeDriver
HTMLUnit driver is a pure Java driver that run in memory without displaying the browser on the screen. It use Rihno as JavaScript engine.

Selenium2 five minutes starting guide
Selenium2 documentation
Selenium2 webdriver new kid

Enjoy using Selenium 2.0 clean API.

---