Sikuli Integration With Selenium Webdriver

Knoldus

Sikuli  image recognition method to identify GUI elements. Sikuli script allows users to automate GUI interaction by using screen shots. Sikuli tool working on image matchmethod. Sikuli take all the element as a image and store in the project. It will trigger the element when it matches the image. We pass the image with parameter.

Sikuli is very useful when we have do not any ID and name because it working on image recognition method. Its very useful when we have stable GUI.

Sikuli is also very useful for window application. We can automate the window application using sikuli. It provides the sikuli script jar file. We can download jar file from sikuli site.

Sikuli easily integrated with selenium webdriver.its open source tool.

First of all download the Sikuli-script jar file and include in your project.

Now we start the sikuli integration with selenium webdriver. So we make a simple…

View original post 44 more words

Advertisements

Data Driven Test Automation with Apache Poi

What is Data Driven Test Automation

To test the functionality of an application it is requires to test with multiple input values. Data driven test automation allows to create test scripts where test data or input/output values are read from an external data files instead of using hard code each time the test run. Data driven test framework allows user to separate their data to the code for re-usability purpose.

Types of external data files

The External data files can be any of them mention below:

  • Excel files
  • CSV files
  • ODBC sources
  • ADO objects

Here we are using excel sheet as an external data source. The test scripts are written in Scala.

How to access the data From excel Files

To access the data from excel files we need to use Apache POI, a project by Apache foundation which enables to use pure Java libraries to read and write the data in Microsoft Office format. For accessing the Apache POI you have to keep the dependency in your project build file.

Apache POI has various components but here we are using only XSSF. You can also use HSSF depends on your format of Microsoft document.

HSSF : Stands for Horribel SpreadSheet Format used for .xls format of excel files.

XSSF : Stands for Xml SpreadSheet Format used for .xlsx format of excel files.

Apache POI dependency

For getting started, first you have to add its dependency in build.sbt .

poi-ooxml 3.13,
poi-ooxml-schemas 3.13,
poi-scratchpad 3.13,
poi  3.1-FINAL,
xbean-spring 4.5,
poi-excelant 3.13

How Data Driven Framework works

data driven test automation framework works in two steps :

  • First step is to create an external data file for which store the test data. Here we are storing data for user login .
  • Populate the data from excel sheet into automation test scripts. It has multiple sub steps:
    • First of all we have to import all the required packages.
    • declare a trait which has multiple methods to access the data from excel file
    • Create a method which will read the data from excel file and write the data in excel file.

excel screenshot1

package dataDrivenTestAutomation

import java.io.File
import java.io.FileInputStream
import org.apache.poi.xssf.usermodel.XSSFWorkbook
import org.apache.poi.xssf.usermodel.XSSFSheet

trait ReadExcel {

      // Location of the excel file
      val excelPath = "/home/knoldus/readexcel.xlsx";

      // Create a object for accessing excel file from given location.
      val file = new File(excelPath) 

      // Create an object for FileInputStream to perform input and output operations
      val fis = new FileInputStream(file) 

      // To load the full excel workbook
      val xfb = new XSSFWorkbook(fis) 

//Create a method for reading data of single row
def getDataFromExcel(sheetNumber: Int, row: Int) = {

      // Create an object for accessing the data from given sheet of loaded workbook
      val sheet = xfb.getSheetAt(sheetNumber) 

      // To access the data of the given row
      val roww = sheet.getRow(row)

      // To get the value of columns and change it into string
      (roww.getCell(0).toString(), roww.getCell(1).toString())
} 

// Create a method to access the full data from given sheet of loaded workbook
def getAllData(sheetNumber: Int) = {

      // Access the first sheet with index 0 of workbook fis stated in this location
      val sheet = xfb.getSheetAt(sheetNumber)

      // To get the all the records of excel sheet.
      val records = sheet.getFirstRowNum+1 to sheet.getLastRowNum
      // Store the data in a list
      val data = for (x <- records.toList) yield {
     // To get the value of the columns and change it into string
val roww = sheet.getRow(x) (roww.getCell(0).toString(), roww.getCell(1).toString()) } data.toList } 

This code enables you to read the data from excel sheet and store it in the form of list.
roww.getcell() method return the value of type cell so its necessary to change it into string.

How to populate the data in test scripts

To populate the data in Test cases we have to extends that trait in our test class and import the required packages.

class LogIn extends Testsetup with ReadExcel {

      val sheet = xfb.getSheetAt(0)
      println("no of records: "+ sheet.getLastRowNum)
Application should must login with register email-id in {

running(TestServer(port, FakeApplication(additionalConfiguration = inMemoryDatabase())), HTMLUNIT) { browser =
getAllData(0).foreach { data =
      println("signin as =" + data)
      signIn(data._1, data._2)
      logout()
      Thread.sleep(5000)
      }
    }
  }

Here I am using XSSF workbook for accessing the .xlsx format excel file if you want to access the xls format excel file you can use HSSF instead of XSSF.

Thank You.

Scriptless Test Automation – Create automated test-cases automatically

Test automation is the activity to creating test script that can run with out human interventions on the same UI that the customer and end user would seen. These scripts can reduce the execution time and cover all the aspects of application.

The first generation of test automation tools provided the macro recording facility which run on the synchronous API rather than UI. The  test execution engine would fire a command, and then wait for the command to complete.A macro based tool was good for such short length automation, By combine a logical sequence of such short length macros, and your test flow is automated.

The second generation of test automation tool provided full‐fledged scripting, or even objected oriented language support to the automation engineer. A lot of tool APIs were present to simplify the common windows based tasks like application launch, file operations, generating elementary test reports, etc.

In a quest to achieve accelerated software delivery, organizations are increasingly adopting Agile development methodology. However, maximizing the benefits of Agile software development requires testing to be performed concurrently with development.

What is script-less and Script-less testing

Script-less is an approach to build an optimized test automation engine by empowering testing team to quickly build automated test cases by sequencing and ready but reusable code assets to ensure the full test coverage.

Script-less means no scripting and programming in the test automation tools native language. it doesn’t means there are no scripting involved. This means while automating test cases there is no need to program scripts  for each test case.

Script-less testing serves to reduce the time required for creating automated tests by considerably reducing the amount of scripting needed and it is no way a substitute for actual coding of an organizational test automation tools. Script-less testing is highly flexible and conventional testing framework with minimal code exposure.

Simple definition of  script-less test automation is an approach that helps users automate their tests without having to script or code using any programming language.”Test automation is a software development process that demands core technical capabilities. Test automation, most often than not, is driven by automation experts who might not necessarily have enough functional expertise about application under test.

Script-less test automation provides a very easy to use interface-

All the good concepts of test automation like data driving, keyword driving and modularity are wrap in a very easy to use software package. All the requirement of test automation script like sequence of keyword, steps with in each keyword, data per step, sequence of keyword for the test and UI object definition are available in a very easy to use interface.
Test automation will continue to deliver what it promises reduce repetitive testing efforts and accelerated regression testing. But going script-less will ensure you achieve these results much faster than promised by script based test automation.
Script-less test automation strives to bridge the gap between functional and technical expertise by allowing functional experts to take the driver seat in test automation.Script-less experience is achieved by abstracting the technology layer by use of work-flow driven approach to build automated test cases along with a set of keyword that run in the background which convert work-flow into scripts.
 scriptless test activity

Benefits of script-less testing 

  1. Requires one time effort of Automation Experts to define the architecture & design the solution, class libraries, custom keywords etc.
  2. Ability to keep up with increased product workload without increase in resources.
  3. Faster execution of automated tests.
  4. Flexible Keyword/Data-Driven approach.
  5. Applicable to all areas of automated testing (Smoke Testing, Regression Testing, User-Acceptence Testing )
  6. Ability to keep up with increased product workload without increase in resources.
  7. Designed for Maintainability.
  8. Increased test coverage as result to fewer product escapes.

Some of the common myths with script-less test automation

  1. Script-less no different from record and playback – Record and playback is capability that users can choose to use to record their tests and play it back to execute them.The recorded scripts contains hard coded test data inputs, cannot handle dynamic situations and is more error prone since it does not perform any validation and error handling on its own. The recorded script does not work in long run as they are not maintainable, scalable, and reliable.Unlike record and playback, the script less approach also provides a flexibility to manage dynamic object and associate multiple data sets.
  2. Script-less means script-free – Script less automation is an experience made possible by building keywords  that are reusable across applications, tools, technologies, platforms etc.The idea is to have our automation experts build a library of simple yet exhaustive keywords that can be easily used by functional experts, allowing them to quickly automate tests without any scripting.Keywords can be of different types like user actions such as “Click”, “Select Item”, “Enter Text”, etc and operations such as arithmetic, file, database, and many more.
    As far as a complete automation suite is concerned, it needs to grow organically from within your environment by carefully integrating business and operational logic step by step until it gets to a point where no further scripting is needed for people who are using it.
  1. Script-less test automation is not maintainable and reliable – Script-less test automation is a well-structured, methodical yet a very flexible approach to handle all types of complexities an application under test has to offer. It eliminates the complexities of test automation tools by building a layer on top, allowing functional users to automate.A well designed script-less approach, maintains complete traceability of all reusable components and maps dependencies throughout the test automation life cycle. Today there are several highly organized tools that offer script-less automation for use in multiple real time test scenarios. The developers of these tools have analysed numerous business cases, operational scenarios, deployment environments before building reusable components for their tools. They offer a high degree of practical reliability as well.
With the evolution of artificial intelligence, big data analytics, and high speed cloud computing, we may in the near future have a taste of script-less testing literally but for now, it is safe to assume that script-less testing is a highly flexible and conventional testing framework with minimal code exposure to users.

 Thanks.