Skip to main content

Automation Testing Questionnaire


Introduction to Automation testing:
Testing is an essential part of a software development process. While testing intermediate versions of products/projects being developed, testing team needs to execute a number of test cases. In addition, prior to release every new version, it is mandatory that the version is passed through a set of “regression” and “smoke” tests. Most of all such tests are standard for every new version of product/project, and therefore can be automated in order to save human resources and time for executing them.
Benefits of using automated testing are the following:
  • Reduction of tests’ time execution and human resources required
  • Complete control over the tests’ results (“actual results” vs “expected results”)
  • Possibility to quickly change test’s preconditions and input data, and re-run the tests dynamically with multiple sets of data
Automation workflow for the application can be presented as follows:
  • First of all it is required to identify tasks that an application has to accomplish.
  • Second, a set of necessary input data has to be created.
  • Third, expected results have to be defined in order one can judge that an application (a requested feature) works correspondingly.
  • Fourth, Executes a test.
  • Finally, Compares expected results with actual results, and decides whether the test has been passed successfully.
Environment Specifications:
  1. Selenium Webdriver (Supports all major browsers, we use Mozilla, chrome and IE)
  2. Eclipse IDE
  3. Java
  4. TestNG
  5. AutoIT Tool (Used to handle Windows popups for Document Uploads and Downloads.)
  6. JExcel or Apache POI to perform operations with excel like read, write and update the excel sheet
This Framework has the following tools:
1. Selenium - Selenium is a well know open source testing framework, which is widely used for testing Web-based applications. It has different components and in that Webdriver has rendered the Selenium Remote Control obsolete, and is commonly referred to as Selenium 2.0.
Selenium Webdriver supports most of all browsers to run your test cases and many programming languages like C#, Java, Python, Ruby, .Net, Perl, PHP, etc.. to create and modify your test scripts.
2. Eclipse IDE: Eclipse is an integrated development environment (IDE) for Java. The Eclipse IDE is the most known product of the Eclipse Open Source project.
3. TestNG - Is a testing framework inspired from JUnit and NUnit. It has extended new functionalities which made it more powerful and easier than the other testing frameworks.
It supports ReportNG (simple HTML reporting plug-in) and XLST (Graphical / Pictorial reports) plug-ins to customize or extend the default TestNG reporting style.
TestNG also provides ability to implement 'IReporter' an interface which can be implemented to generate a Customized TestNG report by users. It has 'generateReport()' method which will be invoked after all the suite has completed its execution and gives the report into the specified output directory.
4. AutoIT - AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks which is not possible with selenium.
You can also refer the other frameworks available here Keyword Driven Framework and Page Object Model Framework
File Formats Used in the Framework:
  1. Properties file – We use properties file to store and retrieve the UI elements of an application or a website and data set file paths. It contains id of the elements, name, xpath or Css selector etc.
  2. Excel files – Excel files are used to pass multiple sets of data to the application.
  3. Xml file – Is used to execute the test scripts. Based on the package or classes or Tests mentioned in the xml file scripts will be executed.
The following figure explains physical structure of files required for Test Automation Framework
Project Structure
The Project Folder Structure: All the basic required folders are created with the sub folders and classes under each folder:--
Automation Project Folder structure
The Following explains the structure in detail:-
UIMap is a concept for defining, storing, and serving UI elements of an application or a website. The UIMap properties file contains a set of ‘key-value’ pairs, where key is an alias of the UI element, and a value is the locator. Click here for more..
Data set stores the data files, Script reads test data from external data sources and executes test based on it. Data sets increases test coverage by performing testing with various inputs and reduce the number of overall test scripts needed to implement all the test cases. Click here for more..
A test is considered as a single action or a sequence of actions, that defines whether a specific feature meets functional requirements. It has multiple test files / packages / class files which will be executed based on the configurations defined in testng.xml. Click here for more..
Test report/results is a document which contains summary of test activities. After execution is completed, it is very important to communicate the test results and findings to the project manager along with the screenshots for failed tests and with that decisions can be made for the release. Click here for More..
In order to create a test suite and run separate test cases, we need framework which drives the automation. Here testng.xml can be called as "driver" which drives several test cases automated using selenium code. Advantage of using TestNG with Selenium is of running multiple test cases from multiple classes using xml configuration file
In order to create a test suite and run separate test cases, we need framework which drives the automation. Here testng.xml can be called as "driver" which drives several test cases automated using selenium code.
Advantage of using TestNG with Selenium is of running multiple test cases from multiple classes using xml configuration file
Another advantage of testng.xml is for entire teams that need to share their test configuration or to be able to specify different parameters or subsets of their tests in different testng.xml files
testng.xml file will have the following structure:-
The root tag of this file is <suite>. as tag <html> which is root tag in html.
<suite> tag can contain one or more <test> tags.
<test> tag can contain one or more <classes> tags.
<classes> tag can contain one or more <method> tags
Here is an example testng.xml file:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
  <suite name="ApplicationName Suite" verbose="1" >
  <test name="testpackage" >
    <classes>
       <class name="testpackage.Test" />
    </classes>
  </test>
   <test name="Regression Testing">
    <classes>
      <class name="testpackage.app.classSample"/>
      <class name="testpackage.app.locationTest"/>
    </classes>
  </test>
</suite>

We can specify package names instead of class names in testng.xml file:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name=" ApplicationName Suite" verbose="1" >
  <test name="Regression1"   >
    <packages>
      <package name="testpackage" />
   </packages>
 </test>
</suite>

In this example, TestNG will look at all the classes in the package “testpackage” and will retain only classes that have TestNG annotations.
We can also specify group tags and method tags to be included and excluded:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name=" ApplicationName Suite" verbose="1" >
<test name="Regression1">
  <groups>
    <run>
      <exclude name="brokenTests"  />
      <include name="checkinTests"  />
    </run>
  </groups>
  <classes>
    <class name="test.IndividualMethodsTest">
      <methods>
        <include name="testMethod" />
      </methods>
    </class>
  </classes>
</test>
</suite>

You can also define new groups inside testng.xml and specify additional details in attributes, such as whether to run the tests in parallel, how many threads to use, whether you are running JUnit tests, etc...                                                 
By default, TestNG will run your tests in the order they are found in the XML file. If you want the classes and methods listed in this file to be run in an unpredictable order, set the preserve-order attribute to false
The below example program explains how to write / set data in spreadsheet without any formatting such as fonts etc.
In order to write anything we need to first create a writable workbook as below which creates the workbook object.
WritableWorkbook workbook = Workbook.createWorkbook(new File("sampletestfile.xls"));
We can also use the existing excel sheet and write the data into excel sheet. But before doing write operations we need to make sure to take the copy of the original file
and then perform the write operations. The below code is the sample code.
Workbook workbook = Workbook.getWorkbook(new File("testSampleData.xls"));
WritableWorkbook workbookCopy= Workbook.createWorkbook(new File("testSampleDataCopy.xls"), workbook);
Now access the sheet from the workbook which is copied from the original.
WritableSheet wSheet = workbookCopy.getSheet(0);
As now we are ready with the worksheet to which we need to pass the data. We need to mention the location (Column number and Row number) to write the data.
The below is the sample code to write the data into excel sheet.
WritableSheet wshTemp = wwbCopy.getSheet(strSheetName);
Label label= new Label(iColumnNumber, iRowNumber, strData);
wshTemp.addCell(label);  
Please find the below working example program:
import java.io.File;
import jxl.Workbook;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.Label;
import jxl.write.WriteException;


public class dataSheet {

    static Workbook wbook;
    static WritableWorkbook wwbCopy;
    static String ExecutedTestCasesSheet;
    static WritableSheet shSheet;
   
    public void readExcel()
    {
    try{
    wbook = Workbook.getWorkbook(new File("path\\testSampleData.xls"));
    wwbCopy = Workbook.createWorkbook(new File("path\\testSampleDataCopy.xls"), wbook);
    shSheet = wwbCopy.getSheet(0);
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    }
   
    public void setValueIntoCell(String strSheetName,int iColumnNumber, int iRowNumber,String strData) throws WriteException
    {
        WritableSheet wshTemp = wwbCopy.getSheet(strSheetName);
        Label labTemp = new Label(iColumnNumber, iRowNumber, strData);
               
        try {
            wshTemp.addCell(labTemp);
             }
            catch (Exception e)
            {
                e.printStackTrace();
            }
    }
   
    public void closeFile()
    {
        try {
            // Closing the writable work book
            wwbCopy.write();
            wwbCopy.close();

            // Closing the original work book
            wbook.close();
        } catch (Exception e)

        {
            e.printStackTrace();
        }
    }
   
    public static void main(String[] args) throws WriteException
    {
        dataSheet ds = new dataSheet();
        ds.readExcel();
        ds.setValueIntoCell("sheet1", 5, 1, "PASS");
        ds.setValueIntoCell("sheet1", 5, 2, "FAIL");
        ds.setValueIntoCell("sheet1", 5, 3, "PASS");
        ds.closeFile();
    }
}
  •  
·         We can pass the formatting information to Excel by overloading the constructor which takes an additional object containing the cell format information.
·         Formatting is required when ever you want to distinguish cell content with other cell contents. Generally, when we update the test cases in excel sheet, we keep all "PASS" in green color and Failed in Red color just to highlight the content.
·         The below syntax and example program helps to write data into excel sheet using formatting styles
·         // Create a cell format for specified font
·         WritableFont cellFont= new WritableFont(WritableFont.TIMES, 12);
·         WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
·         and In order to define the font color, we use the below statement.
·         cellFont.setColour(Colour.RED);
·         // Create the label, specifying content and format
·         Label lab1 = new Label(iColumnNumber, iRowNumber, strData, cellFormat);
·         sheetTemp.addCell(lab);
·         We can pass the same format to different cells. We need to share the same object that is created in the above.
·         Label lab2 = new Label(iColumnNumber, iRowNumber, strData, cellFormat);
·         sheetTemp.addCell(lab);
·         Please find the below example program:
·         import java.io.File;
·         import jxl.Workbook;
·         import jxl.write.WritableSheet;
·         import jxl.write.WritableWorkbook;
·         import jxl.format.Border;
·         import jxl.format.BorderLineStyle;
·         import jxl.format.Colour;
·         import jxl.write.Label;
·         import jxl.write.WritableCellFormat;
·         import jxl.write.WritableFont;
·         import jxl.write.WriteException;
·          
·         public class dataSheet {
·          
·           static Workbook wbook;
·           static WritableWorkbook wwbCopy;
·           static String ExecutedTestCasesSheet;
·           static WritableSheet shSheet;
·          
·           public void readExcel()
·           {
·           try{
·           wbook = Workbook.getWorkbook(new File("D:\\Dev\\SampleTest\\datasheets\\testSampleData.xls"));
·           wwbCopy = Workbook.createWorkbook(new File("D:\\Dev\\SampleTest\\datasheets\\testSampleDataCopy.xls"), wbook);
·           shSheet = wwbCopy.getSheet(0);
·           }
·           catch(Exception e)
·           {
·                  e.printStackTrace();
·           }
·          
·           }      
·          
·           public void setValueIntoCell(String strSheetName,int iColumnNumber, int iRowNumber,String strData) throws WriteException
·           {
·                  WritableSheet wshTemp = wwbCopy.getSheet(strSheetName);
·                  WritableFont cellFont = null;
·                  WritableCellFormat cellFormat = null;
·                 
·                  if(strData.equalsIgnoreCase("PASS"))
·                  {
·                          cellFont = new WritableFont(WritableFont.TIMES, 12);
·                          cellFont.setColour(Colour.GREEN);
·                          cellFont.setBoldStyle(WritableFont.BOLD);
·                         
·                          cellFormat = new WritableCellFormat(cellFont);
·                          cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN);              
·                  }
·                 
·                  else if(strData.equalsIgnoreCase("FAIL"))
·                  {
·                          cellFont = new WritableFont(WritableFont.TIMES, 12);
·                          cellFont.setColour(Colour.RED);
·                          cellFont.setBoldStyle(WritableFont.BOLD);
·                                 
·                          cellFormat = new WritableCellFormat(cellFont);
·                          cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
·                  }
·                 
·                  else
·                  {
·                          cellFont = new WritableFont(WritableFont.TIMES, 12);
·                          cellFont.setColour(Colour.BLACK);
·                                 
·                          cellFormat = new WritableCellFormat(cellFont);
·                          cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
·                          cellFormat.setWrap(true);            
·                  }
·                 
·                  Label labTemp = new Label(iColumnNumber, iRowNumber, strData, cellFormat);    
·                  try {
·                          wshTemp.addCell(labTemp);
·                         
·                          }
·                          catch (Exception e)
·                          {
·                                  e.printStackTrace();
·                          }
·           }
·          
·           public void closeFile()
·           {
·                  try {
·                          // Closing the writable work book
·                          wwbCopy.write();
·                          wwbCopy.close();
·          
·                          // Closing the original work book
·                          wbook.close();
·                  } catch (Exception e)
·                   {
·                          e.printStackTrace();
·          
·                  }
·            }
·          
·           public void main(String[] args) throws WriteException
·           {
·                  dataSheet ds = new dataSheet();
·                  ds.readExcel();
·                  ds.setValueIntoCell("Sheet1", 5, 1, "PASS");
·                  ds.setValueIntoCell("Sheet1", 5, 2, "FAIL");
·                  ds.setValueIntoCell("Sheet1", 5, 3, "N/A");
·          
·           }      
·         }
·         The Above program will copy the original sheet. Now in the sheet which is copied will be updated with 'PASS', 'FAIL' and 'N/A' with styles defined.
There are different ways to handle file uploads with Selenium Webdriver.
The First and the Easy way is simple case of just finding the element and typing the absolute path of the document into it.
HTML code should look similar to this :
<input type="file" name="datafile">
Syntax:
//Find the element of upload button and send the path
WebElement element= driver.findElement(By.name("datafile"));
element.sendKeys("C:\Users\Easy\Desktop\testfile.txt");
NOTE: This works only when the textbox is enabled. So please make sure that the input element is visible.
The OTHER WAY to Handle File Upload
What If there is no text box / input tag to send the file path using Sendkeys method????
You will have only a button (Customized button) and when click on browse button, browser opens a window popup and to select the file from windows, And as we know selenium will not support OS controls.
We can use AutoIt tool (open source tool) which takes the responsibility to upload the file.
About AutoIT : AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.
We need to call the AutoIt script after clicking on the upload button. Immediatly ater clicking on Upload button, the control should be transfered to AutoIt which takes care of uploading the file.
Syntax:
Runtime.getRuntime().exec("AutoIt .exe filepath");
Download and Install Autoit tool from Download AutoIt
Example:
Runtime.getRuntime().exec("D:/fileupload.exe");
AutoIt script should have the following:
Step 1 : First After clicking on 'Upload' button, the cursor will move to the Window popup.
The below step should be the first line in the script. 'File Upload' is the name of the window popup when opened with Mozilla. The name changes depending on the browser.
Mozilla - File Upload
Chrome - Open
and for IE - Choose File to Upload
WinWaitActive("File Upload")
Step 2 : Once the window popup is active, we should send the path of the document which need to be uploaded.
 Send("Full path of the document")
Step 3 : After that we need to click on Open button which will upload the document.
Send("{ENTER}")
  •  

Comments

Popular posts from this blog

What do we mean by Usability?

Many definitions of usability are available, few of them are: 1) In simple words it is "The ease of use". 2) It is the amount of effort required in learning, operating, preparing inputs, and interpreting the outputs of an application. 3) Technical definition prescribed in ISO 9241-11 is: "The extent to which a product can be used by specified users to achieve specified goals with Effectiveness, Efficiency and Satisfaction, in a specified Context of use".  This testing is also called as 'Testing for User-Friendliness'. This testing is done if User Interface of the application stands an important consideration and needs to be specific for the specific type of user. Usability testing is the process of working with end-users directly and indirectly to assess how the user perceives a software package and how they interact with it.    This process will uncover areas of difficulty for users as well as areas of strength. Usability "means...

Application Lifecycle Management

Application Lifecycle Management Lifecycle the word means “Series of stages through which something passes during its lifetime.” Application lifecycle is similar to giving birth to a young one as per the God’s management. Creating an application is not a big task, but adding the word Management in that Application  Lifecycle is adding a process of distributing with or governing things or people.  When Process comes in a picture, we bound to work according to that, which give the  picture of Application Lifecycle Management. Accumulation process is not that you are bound to move in that particular line only, but it  means you are moving in the correct direction which will give success and 99.9%  assurance that the Project on which you have implemented is having a correct planning,   great controlling, and using the resources in an organized behavior. Application Lifecycle Management is controlling of a software application from planning...

Project Estimation Template

  Read Me All white cells are editable in the estimation template Estimation Summary 1 In this sheet, mention the basic project information. 2 This sheet gives the amount of effort estimated for each phase, based on the effort distribution. 3 ‘Engineering effort’ is the total amount of effort estimated for the project 4 Total Size (complexity Point) is the calculated value of the complex points or the size of the work that has to be performed. 5 ‘Project Management Effort’ is the percentage of Engineering Effort that will be required for project management. 6 ‘Total Effort (Hours)’ is the sum of ‘Engineering Effort’ and ‘Project Management Effort’ 7 ‘Contingency %’ is the percentage of total effort that counts for an incidental expense 8 ‘Grand Total Effort (Hours)’ is the sum of ‘Total Effort (Hours)’ and ‘‘Contingency %’’ 9 ‘Assumptions’ and Risks: List all the assumptions and risks related to estimation Estimation Criteria 1 Mention the criteria for various complexities i.e. Low...