Friday 28 September 2012

Selenium Frameworks

Types of Framework

Any framework is made up of a number of reusable modules & function libraries that are developed with the following characteristics in mind:

Maintainable
Reusable
Manageable
Accessible
Robust
Flexibility
Measurable


Frame work has several types and most popular are the below :
 

Frame work has several types and most popular are the below :

a.Keyword driven frame work
b.Data driven driven frame work
c.Hybrid framework

Key word Driven Frame work :

Keyword driven framework is an action based test method used in planing and implementation of automation.

Data Driven Framework :

Data driven is the design of possible inputs what may be given by the end user.
This would cover maximum probabilities of an input data.
It can either be Spread sheet(excel)/sql/CSV.
We have to connect and pass the values to the respective field or element.
The data should be designed by the experienced person on the project. It may be a client or even non technical person but should be more familiar from an end users prospective.
We have to map the file path properly.

Hybrid Framework:

The Hybrid Automation Framework is otherwise referred to in the industry as a "Hybrid Keyword Data Driven Automation Framework".  


Referal Sites

http://www.gcrit.com/forums/viewtopic.php?f=29&t=109

http://zomobo.net/keyword-driven
 

http://www.youtube.com/watch?v=KL4Y7cWiK4g&feature=player_embedded
 

http://www.youtube.com/watch?v=JMZeaF0ST4w&feature=channel
 

http://www.youtube.com/watch?v=1ZV8pZAKkDQ&NR=1
 

http://www.youtube.com/watch?v=A6ND9pRRBY8&NR=1
 

http://www.whatsontv.co.uk/video/youtube/search/keyword-driven
 

Selenium Refereal sites

http://www.mkyong.com/



http://whytotest.blogspot.in/2010/05/selenium-test-framework.html

http://anoopjshetty.wordpress.com/2012/04/19/behaviour-driven-development-bdd-in-net-using-specflow-selenium-and-nunit/

http://codedetective.blogspot.in/2011/11/setting-up-selenium-webdriver-using-c.html

http://help.utest.com/testers/crash-courses/functional/automation-tools--selenium-102

http://www.savevid.com/video/selenium-video-training-datadriven-framework-and-hybrid-framework-comparison.html

http://testng.org/doc/index.html

http://selenium-tutorial.blogspot.in/2012/04/uploading-file.html

http://oxpedia.org/wiki/index.php?title=Automated_GUI_Tests

http://xebee.xebia.in/2012/05/29/creating-automation-framework-using-selenium-and-test-ng-2/

http://www.way2automation.com/selenium_tutorial/selenium-hybrid-datadriven-keyword-framework

-tutorial.html

http://www.seleniumwiki.com/selenium-rc/selenium-keyword-driven-framework/


http://executeautomation.com/blog/blog_mod/data-driven-testing-in-selenium-using-jxl-part-2/

http://code.google.com/p/selenium/wiki/AdvancedUserInteractions

http://www.kavinschool.com/content/selenium-tuition-bayarea/39-selenium-course/54-advanced-s

elenium-using-java-language

http://www.ijcst.com/vol23/1/prasanth.pdf

http://code.google.com/p/selenium/wiki/PageFactory

http://learnseleniumautomation.blogspot.in/2012/03/window-handle-example-with-selenium.html

http://www.ibm.com/developerworks/web/library/wa-seleniumgrid/index.html

http://www.8bitavenue.com/2012/03/gui-testing-using-sikuli-and-java/

http://eureka.ykyuen.info/2010/06/26/selenium-integrate-the-selenium-tests-into-maven-build/

http://www.way2automation.com/

http://mearra.com/blogs/jani-palsamaki/creating-and-running-simple-selenium-webdriver-test

http://code.google.com/p/selenium/wiki/SeleniumEmulation

http://automation.youplayoff.com/category/selenium/


http://qaselenium.blogspot.in/2011/01/selenium-automation-framework-design.html

http://seleniumexamples.com/blog/examples/selenium2-in-net-framework/

http://robotframework-seleniumlibrary.googlecode.com/hg/doc/SeleniumLibrary.html?r=2.8

https://blogs.oracle.com/rajeshthekkadath/

http://en.wikipedia.org/wiki/Selenium_%28software%29

http://www.f14testing.com/archives/1532

http://functionaltestautomation.blogspot.in/2009/10/dataprovider-data-driven-testing-with.html

http://www.javacodegeeks.com/2012/04/integration-testing-with-selenium.html

http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/html5/package-summary.html

http://sauceio.com/index.php/2011/12/selenium-testing-framework-part-3-putting-it-all-togeth

er/

http://selftechy.com/2011/06/02/parameterization-of-selenium-tests-with-microsoft-excel

http://sauceio.com/index.php/2011/11/selenium-testing-framework-pt-2-base-classes/

http://www.kavinschool.com/content/selenium-tuition-bayarea/39-selenium-course/54-advanced-s

elenium-using-java-language

http://hop2croft.wordpress.com/2011/09/17/spring-mvc-basic-example-with-maven/

http://www.seleniumwiki.com/selenium-rc/selenium-rc-test-framework-using-xml-data-structure/

http://marcovaltas.com/2009/02/19/running-selenium-with-testng.html

http://blog.varunin.com/

http://en.wikipedia.org/wiki/Data-driven_testing

http://thangselenium.blogspot.in/


http://sqahome.blogspot.in/2010/06/selenium-framework-structure-java.html

http://www.wallix.org/2011/07/26/how-to-use-robotframework-with-the-selenium-library/

http://qtpselenium.com/selenium-tutorial/selenium-training-hybrid-framework/

http://automationtestingsimplified.wordpress.com/2011/08/18/how-to-do-data-driven-testing-us

ing-selenium-2-webdriver/

http://wiki.zimbra.com/wiki/Testing:_Selenium:_ZimbraSelenium_SampleTestCase

http://code.google.com/p/selenium/wiki/PageObjects

http://marakana.com/bookshelf/selenium_tutorial/project.html

http://in.linkedin.com/pub/selenium-rc-webdriver-tutorial/51/b7/49

http://code.google.com/p/robotframework-seleniumlibrary/

http://blog.codecentric.de/en/2010/07/file-downloads-with-selenium-mission-impossible/

http://www.pushtotest.com/testing-with-selenium#tutorial

http://seleniumrc.wordpress.com/

http://qtp-help.blogspot.in/p/selenium-training.html

http://www.seleniumtests.com/2012/01/selenium-2-methods-are-no-more-weird.html?utm_source=BP_recent

http://candidjava.com/keyword-this-in-java-with-example-program

https://github.com/Ardesco/Ebselen/blob/master/ebselen-core/src/main/java/com/lazerycode/ebselen/customhandlers/ExcelHandler.java

http://shanmugavelc.blogspot.in/2010/09/datadriven-test-using-selenium-nunit.html

http://vimeo.com/46412735

http://computer.motiontopic.net/s/Selenium-Data-driven-framework

Selenium Grid

http://code.google.com/p/selenium/wiki/Grid2
http://deors.wordpress.com/2012/02/02/selenium-webdriver-grid-2/
http://technologyandleadership.com/30-feet-view-of-test-automation-framework-with-selenium/

selenium with flash

http://code.google.com/p/flash-selenium/


http://www.softwaretestingtutorials.org/packages/


selenium with ant

http://hedleyproctor.com/2011/07/automating-selenium-testing-with-testng-ant-and-cruisecontrol/


selenium Index

http://www.sqaforums.com/showflat.php?Cat=0&Number=716574&Main=714887

http://www.citehr.com/374186-best-institute-learning-selenium-testing.html

http://forum.softwaretestinghelp.com/index.php?topic=446.0

http://grokbase.com/p/gg/selenium-users/125bve6d3m/is-anyone-provide-me-code-for-data-driven-testing-in-selenium-webdriver-in-java-junit-framework-plz-it-is-urgent

http://ahmedabad.olx.in/selenium-training-in-ahmedabad-iid-249982843


http://www.automation.lifegoeasy.com/Selenium-Webdriver-Java-Syllabus

http://seleniumtraining.weebly.com/selenium-automation.html

http://www.360logica.com/test-automation-services/functional-automation-framework


Testng

http://ravisha-selenium.blogspot.in/

DataDriven framework

http://executeautomation.com/blog/tag/data-driven-testing/

http://functionaltestautomation.blogspot.in/2009/10/dataprovider-data-driven-testing-with.html

http://qtpselenium.com/selenium-tutorial/selenium-training-data-driven-framework/

http://automationtestingsimplified.wordpress.com/2011/08/18/how-to-do-data-driven-testing-using-selenium-2-webdriver/

http://automationtestingsimplified.wordpress.com/2011/05/31/hybrid-testing-data-keyword-driven-using-selenium/

http://www.softwaretestingclub.com/video/selenium-data-driven-automation-framework-selenium-rc-junit

http://testerinyou.blogspot.in/2010/10/how-to-do-data-driven-testing-using.html

http://www.seleniumelearn.com/free-selenium-training-tutorial-videos

http://www.seleniumwebdriver.com/webdriver-tutorials/advance-selenium-rc-webdriver-tutorials-with-frameworks/msg16333/?PHPSESSID=b0af0d93c11942fedcc8c26d0ac04ec0#msg16333

http://lrnselenium.com/?category_name=automation-framework

http://selenium-suresh.blogspot.in/2012/07/data-driven-testing-using-selenium-rc_24.html

http://hedleyproctor.com/2011/07/automating-selenium-testing-with-testng-ant-and-cruisecontrol/

http://testingchronicle.blogspot.in/2012/05/selenium-keyword-driven-and-data-driven.html

https://sites.google.com/site/joinqahub/Selenium-tutorial-for-beginners

http://executeautomation.com/blog/blog_mod/data-driven-testing-in-selenium-using-jxl-part-2/

http://www.gcrit.com/forums/viewtopic.php?f=29&t=109
http://zomobo.net/keyword-driven
http://www.youtube.com/watch?v=KL4Y7cWiK4g&feature=player_embedded
http://www.youtube.com/watch?v=JMZeaF0ST4w&feature=channel
http://www.youtube.com/watch?v=1ZV8pZAKkDQ&NR=1
http://www.youtube.com/watch?v=A6ND9pRRBY8&NR=1
http://www.whatsontv.co.uk/video/youtube/search/keyword-driven
 

Thursday 20 September 2012

Reading and Writing CSV Formated Data

Reading/Writing an excel document like you requested, you can use the CSV format


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class CsvWriter {
 
public static void main(String args[]) throws IOException {

 
String fileName = "test.xls";

 
PrintWriter out = new PrintWriter(new FileWriter(fileName));
  out
.println("a,b,c,d");
  out
.println("e,f,g,h");
  out
.println("i,j,k,l");
  out
.close();

 
BufferedReader in = new BufferedReader(new FileReader(fileName));
 
String line = null;
 
while ((line = in.readLine()) != null) {

   
Scanner scanner = new Scanner(line);
   
String sep = "";
   
while (scanner.hasNext()) {
   
System.out.println(sep + scanner.next());
    sep
= ",";
   
}
 
}
  in
.close();
 
}
}

Wednesday 19 September 2012

Testing Interview Questions

Difference between Performance Testing, Load Testing and Stress Testing

Performance testing - It is performed to evaluate the performance of components of a particular system in a specific situation. It very wide term. It includes: Load Testing, Stress Testing, capacity testing, volume testing, endurance testing, spike testing, scalability testing and reliability testing etc. This type of testing generally does not give pass or fail. It is basically done to set the benchmark & standard of the application against Concurrency / Throughput, Server response time, Latency, Render response time etc. In other words, you can say it is technical & formal evaluation for responsiveness, speed, scalability and stability characteristics.

 

Load Testing is subset of performance testing. It is done by constantly increasing the load on the application under test till the time it reaches the threshold limit. The main goal of load testing is to identify the upper limit of the system in terms of database, hardware and network etc. The common goal of doing the load testing is to set the SLAs for the application. Example of load testing can be:

Running multiple applications on a computer simultaneously - starting with one application, then start second application, then third and so on....Now see the performance of your computer.

Endurance test is also a part of load testing which used to calculate metrics like Mean Time Between Failure and Mean Time to Failure.

Load Testing helps to determine:

Throughput

Peak Production Load

 Adequacy of H/W environment

Load balancing requirements

How many users application can handle with optimal performance results

How many users hardware can handle with optimal performance results

Stress testing - It is done to evaluate the application's behaviour beyond normal or peak load conditions. It is basically testing the functionality of the application under high loads. Normally these are related to synchronization issues, memory leaks or race conditions etc. Some testing experts also call it as fatigue testing. Sometimes, it becomes difficult to set up a controlled environment before running the test. Example of Stress testing is:

 

A banking application can take a maximum user load of 20000 concurrent users. Increase the load to 21000 and do some transaction like deposit or withdraw. As soon as you did the transaction, banking application server database will sync with ATM database server. Now check with the user load of 21000 does this sync happened successfully. Now repeat the same test with 22000 thousand concurrent users and so on.

Spike test is also a part of stress testing which is performed when application is loaded with heavy loads repeatedly and increase beyond production operations for short duration.

Stress Testing helps to determine:

Errors in slowness & at peak user loads

Any security loop holes with over loads

How the hardware reacts with over loads

Data corruption issues at over loads

 

Reading Data from excel file

How to read data from Excel file using Java

 

 

import java.io.*;
import java.sql.*;
public class ExcelReadTest{
public static void main(String[] args){ 
 Connection connection = null;
try{
 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 Connection con = DriverManager.getConnection( "jdbc:odbc:exceltest" );
 Statement st = con.createStatement();
 ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );
 
 ResultSetMetaData rsmd = rs.getMetaData();
 int numberOfColumns = rsmd.getColumnCount();
 
 
 while (rs.next()) {
 for (int i = 1; i <= numberOfColumns; i++) {
 if (i > 1) System.out.print(", ");
 String columnValue = rs.getString(i);
 System.out.print(columnValue);
 } 
 
System.out.println(""); 
}
 
st.close();
con.close();
}
catch(Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
}
 
 

OR

WorkbookSettings ws = new WorkbookSettings();   

ws.setLocale(new Locale("en","EN"));   

Workbook workbook = Workbook.getWorkbook(file);              

Sheet s = workbook.getSheet(0);         

LabelCell lcdate = s.findLabelCell("Date");          

LabelCell lcitem = s.findLabelCell("Item");                                  

LabelCell lcamount = s.findLabelCell("Amount");                                 

LabelCell lctype = s.findLabelCell("Type");                 

int columns = s.getColumns();          

   int rows = s.getRows();         

      System.out.println("col -->>> "+columns+"  rows -->>> "+rows);  


To print the data


String data;     

  for(int col = 0;col < columns;col++)         {             for(int row = 0;row < rows;row++)             {                data = s.getCell(col, row).getContents();   

       // Code to display ....   

       }  

 

 

(OR)

 

 

Navigate to this url's

http://poi.apache.org/index.html 

 http://www.coderanch.com/t/465901/JDBC/databases/insert-data-excel-file-java

http://www.ibm.com/developerworks/library/x-jxmlexl/index.html 

http://www.avajava.com/tutorials/lessons/how-do-i-read-from-an-excel-file-using-poi.html?page=1 

http://mrbool.com/reading-excel-file-with-java/24562 

Thursday 13 September 2012

How do you make Selenium wait for the page to load in Selenium 2.0?

// Sleep until the div we want is visible or 5 seconds is over

long end = System.currentTimeMillis() + 5000;
while (System.currentTimeMillis() < end) {
   
// Browsers which render content (such as Firefox and IE) return "RenderedWebElements"
   
RenderedWebElement resultsDiv = (RenderedWebElement) driver.findElement(By.className("gac_m"));

   
// If results have been returned, the results are displayed in a drop down.
   
if (resultsDiv.isDisplayed()) {
     
break;
   
}
}

 

(or)

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

 

How to Take a screenshot using Selenium WebDriver?

WebDriver driver = new FirefoxDriver();
driver
.get("http://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));

 

How to stop the selenium server until a popup opens? 

selenium.WaitForPopUp("id=popup_container", "30000");

 

How to fetch data from table using Selenium WebDriver ?

<table> <tbody> <tr><td>data</td><th>data</th><td>data</td><td>data</td></tr> <tr><td>data</td><th>data</th><td>data</td><td>data</td></tr> <tr><td>data</td><th>data</th><td>data</td><td>data</td></tr> </tbody> </table>

// Grab the table 

WebElement table = driver.findElement(By.id(searchResultsGrid)); 

 // Now get all the TR elements from the table

 List<WebElement> allRows = table.findElements(By.tagName("tr"));

 // And iterate over them, getting the cells 

for (WebElement row : allRows) { 

 List<WebElement> cells = row.findElements(By.tagName("td")); 

 for (WebElement cell : cells) { 

 //  so on 

 } 

}

 

// List<WebElement> cells = row.findElements(By.xpath("./*"));

 

Q) how to find out a text is available in current webpage using WebDriver ?

import org.openqa.selenium.firefox.FirefoxDriver;
import com.thoughtworks.selenium.*; 

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;

public class SearchingText {

    static WebDriver driver = new FirefoxDriver();
    static Selenium selenium = new WebDriverBackedSelenium(driver, "http://");


    public static  void find(){


    driver.get("http://google.com");
    boolean b =driver.getPageSource().contains("Telugu");
    System.out.println(b);
    driver.quit();
 

    }
   

      public static void main(String[] args) {
        

      find();
   }
 } 

 

How to automate onblur through selenium RC 

How to automate onblur through selenium RC .
How to automate lost focus through selenium.


I faced the problem while automating the form submit. All of the form fields are having some action on their lost focus.
The onblur event occurs when an object loses focus.
For example : I have two fields First Name and Last Name. When i enter first name and press tab then it loses its focus and onblur function gets called.
and its calls upperCase and it changes the first name in Upper case.
the same case with Last Name. When i enter last name and press tab it calls blur function lowerCase and changes the letters in lower case.

But the problem in automation is i cant automate lost focus. when we type in first name and last name it simply types in first name and last name text box.
It does not call onblur function upper case and lower case and does not change the letter respectively.

so, fireEvent is a special command in selenium which helps in automating onblur function.

this is html of the element and blur javascript functions 

 <html>
<head>
<script type="text/javascript">
function upperCase()
{
var x=document.getElementById("fname").value;
document.getElementById("fname").value=x.toUpperCase();
}
function lowerCase()
{
var x=document.getElementById("lname").value;
document.getElementById("lname").value=x.toLowerCase();
}
</script>
</head>
<body>
Enter your First Name: <input type="text" id="fname" onblur="upperCase()" />
<br />
Enter your Last Nast: <input type="text" id="lname" onblur="lowerCase()" />
</body>
</html>

 

 selenium.type("fname", "ramesh");
 selenium.fireEvent("fname", "blur");
 selenium.type("lname", "reddy");
 selenium.fireEvent("lname", "blur");

How this works is :

First this will type "ramesh" in First Name and then selenium.fireEvent("fname", "blur"); this will call the onblur fuction "upperCase()" which changes the First Name in upper case "ramesh".
then it types in Last Name and then selenium.fireEvent("lname", "blur"); which means it will press tab and lost the function and on the lost focus it calls
blur function lowerCase which changes the Last Name in lower case.

 

Running test case in multiple browsers parallely in WebDriver

 we can run test script in different browsers parallely using web driver. Write one test script and configure in testng xml to run that test case in IE, firefox and chrome parallely.


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class ParallelRunning {

 private  WebDriver driver=null;
 @BeforeTest
 @Parameters ({"BROWSER"})
 public void setup(String BROWSER){
  System.out.println("Browser: " + BROWSER);

  if (BROWSER.equals("FF")) {
   System.out.println("FF is selected");
   driver = new FirefoxDriver();
  } else if (BROWSER.equals("IE")) {
   System.out.println("IE is selected");
   driver = new InternetExplorerDriver();
  } else if (BROWSER.equals("HU")) {
   System.out.println("HU is selected");
   driver = new HtmlUnitDriver();
  } else if (BROWSER.equals("CH")){
   System.out.println("Google chrome is selected");
   driver = new ChromeDriver();
  }
 }

 @Test
 public  void testParallel()throws Exception{

  driver.get("http://www.google.com");
  Thread.sleep(5000);
  WebElement search = driver.findElement(By.name("q"));
  search.sendKeys("automation  by ramesh");
  search.submit();
  Thread.sleep(5000);
  Assert.assertTrue(driver.getPageSource().contains("xxxxxxxxxxxxxxxxxxxxxxxxxxxx"));
  driver.findElement(By.xpath("//a[contains(@href,'seleniumresource.blogspot.com')]")).click();
  Thread.sleep(15000);
  Assert.assertTrue(driver.getPageSource().contains("working as Associate Manager @freelancher"));
  driver.quit();

 }
}
In the above sample program BROWSER is a variable which value would be passed from TestNG.xml and TestNG.xml will run the test multiple time each time BROWSER value would be set with different browser name and test will check the BROWSER value and decide which browser test will run.

TestNG.xml

<?xml version="1.0" encoding="UTF-8"?>
<suite name="webDriver" parallel="tests">
  <test name="WebDriverDemo Witn FF" preserve-order="true">
  <parameter name="BROWSER" value="FF" />
  <classes>
   <class name="com.freelancher.ParallelRunning" />
  </classes>
 </test>
  <test name="WebDriverDemo with IE" preserve-order="ture">
  <parameter name="BROWSER" value="IE"></parameter>
  <classes>
   <class name="com.freelancher.ParallelRunning"></class>
  </classes>
 </test>

 <test name="WebDriverDemo with HTML unit" preserve-order="true">
  <parameter name="BROWSER" value="HU"></parameter>
  <classes>
   <class name="com.freelancher.ParallelRunning"></class>
  </classes>
 </test>

  <test name="WebDriverDemo with HTML unit" preserve-order="true">
  <parameter name="BROWSER" value="CH"></parameter>
  <classes>
   <class name="com.freelancher.ParallelRunning"></class>
  </classes>
 </test>
</suite>

 

 

How to verify the text ignoring cases sensitivity in selenium ?

Some times we need to verify the text on the webpage no matter is upper cases or lower cases or proper.
We just need to verify the text on the web page ignoring their cases sensitivity.
REGEXPI is used to avoid cases sensitive to verify the text on the page.

Lets say i want to verify the text "seleniumresource is good blog for selenium" No matter its in upper cases or lower case or proper case.

Then use REGEXPI in selenium command selenium.isTextPresent or verifyTextPres

verifyTrue(selenium.isTextPresent("regexpi:SELENIUMRESOURCE IS GOOD BLOG FOR SELENIUM"));

verifyTrue(selenium.isTextPresent("regexpi:

SELENIUMRESOURCE is good blog for selenium"));

verifyTrue(selenium.isTextPresent("regexpi:SELENIUMRESOURCE Is GoOd Blog for SELENIUM"));

verifyTrue(selenium.isTextPresent("regexpi:SELENIUMRESOURCE is good blog for selenium"));

 

 

 

 

Wednesday 12 September 2012

Designing Test Automation Framework with Selenium

Designing Test Automation Framework with Selenium

 

Do we need to go for Test Automation? If yes, then which is the tool? If we straight away start automating test cases what are all the technical challenges we might face? Do we need a framework for Automation? How we go about designing a framework?

These are all the questions popup when we want to start Test Automation. Okay, let us start exploring answers for the above questions.

If there are hundreds of test scenarios which needs to be executed on each build then it will be a tedious task and error prone.  Because a Test Engineer might make mistakes while entering the test data and output might be wrong.  We can avoid such situations by automating the test cases.

Before selecting a tool for Test Automation, we need to analyze the technologies used for different UI components. For example, Java Swing components, Telerik controls, ExtJS tables, Ajax, Silver light, Flex / Flash controls, etc. If we want to use Selenium as Test Automation tool then the first and foremost thing needs to be checked is whether the application is a Web Application. If so, then check whether most of the UI controls are identified by the Selenium. If more than 70% of the test cases can be automated then definitely we can go ahead and automate the test cases.

In order to handle large number of test cases we need to have a clear cut strategy for designing the framework. Some of the framework functionalists can be mentioned as follows:

  1. If there is any unhandled exception, then the execution should not stop.  Particular test scenario should be stopped and continue with the next scenario.

  2. Screen shots must be taken for each error so that analyzing the failures should be easy.

  3. Proper exception handling should be done in the framework.

  4. Proper naming convention should be used

  5. Avoid hard coding test data

  6. Test Data should be parametrized using external means such as XML s, Database, Spreadsheet, etc.

  7. Logs should be created that makes life easier while analyzing the Test Execution

  8. Proper folder structure should be created.



Datadriven framework is used when there are test cases which run for multiple sets of test data. Follow the below steps to create Data Driven framework:

1. Create a folder structure inside the eclipse workspace. i.e. source files, test data, results, logs, error screenshots, etc
2. Use J Unit / TestNG to write test scripts (automated test case) or write your own Java code (run as Java application – need to have main method)
3. Parametrize the automated test cases and iterate them for all the test data sets.

Tuesday 11 September 2012

Selenium WebDriver – Handling JavaScript Popups

Selenium WebDriver – Handling JavaScript Popups

public class HandlingPopup  {

static WebDriver driver = new FirefoxDriver();

 public static void Handle(){

//switching focus to alert box
Alert alert =driver.switchTo().alert();

//Get text from the alert box
 System.out.println(alert.getText());

//click on Ok

 alert.accept();

//cancel the popup

driver.quit();

public static void main(String args[]){

 Handle();

 }
}

selenium Interview Questions

Q1. What is Selenium?

 Ans. Selenium is a set of tools that supports rapid development of test automation scripts for web based applications. Selenium testing tools provides a rich set of testing functions specifically designed to fulfill needs of testing of a web based application.


Q2. What are the main components of Selenium testing tools?

Ans. Selenium IDE, Selenium RC and Selenium Grid

Q3. What is Selenium IDE?

Ans. Selenium IDE is for building Selenium test cases. It operates as a Mozilla Firefox add on and provides an easy to use interface for developing and running individual test cases or entire testsuites. 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.


Q4. What is the use of context menu in Selenium IDE?
Ans. It allows the user to pick from a list of assertions and verifications for the selected location.
 

Q5. Can tests recorded using Selenium IDE be run in other browsers?
Ans. Yes. Although Selenium IDE is a Firefox add on, however, tests created in it can also be runin other browsers by using Selenium RC (Selenium Remote Control) and specifying the name of the test suite in command line.
 

Q6. What are the advantage and features of Selenium IDE?
 Ans. 1. Intelligent field selection will use IDs, names, or X Path as needed2. It is a record & playback tool and the script format can be written in various languages including: C#, Java, PERL, Python, PHP, HTML3. Auto complete for all common Selenium commands4. Debug and set breakpoints5. Option to automatically assert the title of every page6. Support for Selenium user-extensions.js file
 

Q7. What are the disadvantage of Selenium IDE tool?
Ans. 1. Selenium IDE tool can only be used in Mozilla Firefox browser.2. It is not playing multiple windows when we record it.
 

Q8. What is Selenium RC (Remote Control)?
Ans. Selenium RC allows the test automation expert to use a programming language for maximum flexibility and extensibility in developing test logic. For example, if the application under test returns a result set and the automated test program needs to run tests on each element in the result set, the iteration / loop support of programming language can be used to iterate through the result set, calling Selenium commands to run tests on each item. Selenium RC provides an API and library for each of its supported languages. 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 the projects automated build environment.
 

 

Q9. What is Selenium Grid?
 Ans. Selenium Grid in the selenium testing suit allows the Selenium RC solution to scale for testsuites that must be run in multiple environments. Selenium Grid can be used to run multipleinstances of Selenium RC on various operating system and browser configurations.
 

. How Selenium Grid works?
 Ans. Selenium Grid sent the tests to the hub. Then tests are redirected to an available Selenium RC, which launch the browser and run the test. Thus, it allows for running tests in parallel with the-entire test suite.
 

Q 11. What you say about the flexibility of Selenium test suite?
[/b]Ans. Selenium testing suite is highly flexible. There are multiple ways to add functionality to Selenium framework to customize test automation. As compared to other test automation tools, itis Selenium¶s strongest characteristic. Selenium Remote Control support for multiple programming and scripting languages allows the test automation engineer to build any logic they need into their automated testing and to use a preferred programming or scripting language of one¶s choice. Also,the Selenium testing suite is an open source project where code can be modified and enhancements can be submitted for contribution.
 

Q12. What test can Selenium do?
Ans. Selenium is basically used for the functional testing of web based applications. It can be used for testing in the continuous integration environment. It is also useful for agile testing
 

Q13. What is the cost of Selenium test suite?
Ans. Selenium test suite a set of open source software tool, it is free of cost.
 

Q14. What browsers are supported by Selenium Remote Control?
Ans. The test automation expert can use Firefox, IE 7/8, Safari and Opera browsers to run tests in Selenium Remote Control.
 

Q15. What programming languages can you use in Selenium RC?
Ans. C#, Java, Perl, PHP, Python, Ruby

 

Q16.What are the advantages and disadvantages of using Selenium as testing tool?
Ans. Advantages: Free, Simple and powerful DOM (document object model) level testing, can beused for continuous integration; great fit with Agile projects.Disadvantages: Tricky setup; dreary errors diagnosis; can not test client server applications.

 

 

Q17.What is difference between QTP and Selenium?
Ans. Only web applications can be testing using Selenium testing suite. However,
QTP can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer,Firefox, Safari, Opera or Conqueror on Windows, Mac OS X and Linux. However,
QTP is limited to Internet Explorer on Windows.
 

QTP uses scripting language implemented on top of VB script. However, Selenium test suite haste flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.
 

Q18. What is difference between Borderland Silk test and Selenium?
Ans. Selenium is completely free test automation tool, while Silk Test is not. Only web application scan be testing using Selenium testing suite. However, Silk Test can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer, Firefox, Safari,Opera or Conqueror on Windows, Mac OS X and Linux. However, Silk Test is limited to Internet Explorer and Firefox.Silk Test uses 4Test scripting language. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.

What makes Automated Software Testing important in the companies?

Tests are repeated quite often during the development cycle as to ensure the quality of the software.

So, whenever the source code is modified tests should be repeated,where in it has to be tested on all supporting operating system and hardware. Doingthis manually would be costly and time consuming, Therefore, automation testing canbe done over and over again at no additional cost and would also save time ascompared to manual testing.

Secondly, automation testing would improve theaccuracy.

Below are some main reasons, why automation testing is crucical in the companies.Firstly automated software testing helps to save time as well money. Every timesource code is modified software tests should be repeated. For each release of thesoftware it may be tested on all supported operating systems and hardwareconfigurations.

Manually repeating these tests is costly and time consuming. Oncecreated, automated tests can be run over and over again at no additional cost and theyare much faster than manual tests.

Secondly, Automated

Software Testing

ImprovesAccuracy as compared to monotonous manual testing. Thirdly, automated softwaretesting can increase the depth and scope of the test to help improve software quality.

Lastly,

Shared automated tests can be used by developers to catch problems quickly before sending to QA. Tests can run automatically whenever source code changes rechecked in and notify the team or the developer if they fail. Features like these save developers time and increase their confidence.Automation test scripts will be used as a way of storing domain/project/task Knowledge gained by the Test Engineers.

Say for example, if a Tester works in project for one year, he might have spent more time for learning the domain, purpose of the project, modules in the project, flow of all functionalists.

He will be familiar with known issues and challenges.

If this Tester leaves from the project, the knowledge gained by him also will leave.

It is very difficult for the newly joining Tester to understand everything from the Test Case document.

I

f automation test scripts are already available then the new Tester can just start the testing by running the automation scripts, without gaining much knowledge about the project.

He can understand the flow/data by seeing the execution of the automation test scripts.

But anyway, he should gain project/domain knowledge to enhance/update the automation scripts further.

So we can say that test automation is a way of storing knowledge.

Friday 7 September 2012

Selenium IDE

1) This is add-on for Mozilla firefox

2) It has record and playback future .

3) Using IDE we can create , update , delete, insert the testcases

4) we can insert comments using Selenium IDE

5) we play all the testcases at one instance ( Test Suite -   No's testcases )

6) Debugging also possible

7)Html is default language

8)we can minize or maximize execution testcases speed

9)Export our testcase to other languages is also possible ( like Java with Junit , C# , Python , PHP , 
  Ruby,Perl) 

10)we can Extend the Selenium IDE functionality By adding external JavaScript file.

Drawback of   Selenium IDE

1) Database testing is not possible

2) Working with external files is not possible

3) Detailed Report is not possible

4) By default IDE is not supporting loops , conditional statements

5) It is Add-on to the  Mozilla Firefox only 


Thursday 6 September 2012

Selenium interview questions

Selenium Interview Questions with Answers

Selenium Resource

1) what do you know about selenium ?

2) what are features  and drawbacks Selenium ?

3) what is Selenium-IDE ?

4) what do you know Selenium-RC ?

5) what are the Drawbacks of Selenium-IDE ?

6) what are the advantages of Selenium ?

7) what is WebDriver ?

8) what are the Advantages of WebDriver ?

9)What are the DrawBacks of WebDriver ?

10)what is mean by Selenium - Grid ?

11) what are advantages and dis advantages of Selenium Grid ?