Saturday, October 27, 2018

How to implement ISuiteListener in TestNG?

ISuiteListener is an interface or TestNG listener provided by TestNG. This listener has two methods onStart() and onFinish(). onStart() method will be invoke before any test suite run and onFinish() method will be invoked after each test suite run.

So when we have a specific tasks that needs to be performed before running a test suite and after finishing the run then this listener will be helpful. Let us understand this listener with an example.

In this example we will be creating two child test suites and these will be executed from another test suite (parent).

How to implement IExecutionListener in TestNG?

IExecutionListener is an interface or TestNG Listener provided by TestNG. This listener monitors the beginning and ending of the TestNG execution.

IExecutionListener interface has two methods onExecutionStart() and onExecutionEnd(). onExecutionStart() will be invoked before TestNG execute any test suite and onExecutionEnd() will be invoked after TestNG executes all test suites.

Let us understand this with an example:

Friday, October 26, 2018

What is the use of TestNG Listeners?

As the name "Listeners" indicating they listen to some events and act accordingly. TestNG provides some interface that will help us to do certain tasks that before and after Suite or Test execution, these interfaces are nothing but TestNG Listeners.

TestNG Listeners are mainly used in generating customized reports and logs. Below are the list of listeners provided TestNG. Each interface is having different abstract methods which can be overridden as per our requirement.

Sunday, October 14, 2018

What is invocationTimeOut in TestNG?

invocationTimeOut: This is a TestNG attribute that defines the maximum period of time that a test method with invocationCount should take to execute/invoke a test method. If the invocationTimeOut has reached before invoking the test method for invocationCount then an exception (ThreadTimeOutException) will be thrown.

And invocationTimeOut should always used with invocationCount otherwise it will be ignored. Let us understand invocationTimeOut with examples.

What is invocationCount in TestNG?

invocationCount: This is a TestNG attribute that defines number of times a test method should be invoked or executed before executing any other test method. If invocationCount = 5, then the test method will be executed 5 times before executing next test method.

Check the below example, In getTitle() test method we are printing the title of the website with invocationCount = 5. And we have another test method secondTest() also.

How to pass heterogeneous parameters from testng.xml in TestNG?

In the previous post we have seen passing only String data as parameters from testng.xml, that is we passed homogeneous data to test method.

But sometimes we have to pass different types of data, that is heterogeneous data to the test method. How to do it in TestNG from testng.xml file.

Check the below example, suppose we are filling a registration form which requires different data types like String, int, long Boolean. Then we need to write a test method that accepts different data types as below

Wednesday, August 8, 2018

How to pass parameters from testng.xml?

We can pass test data as parameters from testng.xml to the tests directly using TestNG Parameters feature.

To pass any parameter from testng.xml we can define "parameter" tag at suite, test and class level in testng.xml. Syntax is <parameter name="name_of_parameter", value="value_of_parameter"/>. We can add any number of parameters for a test. Please see the below screenshot.


To use the parameters in the test methods, we have to use @Parameters annotation provided by TestNG. And @Parameters annotation can be used with the methods that has @Test, @BeforeXXXX, @AfterXXXX or @Factory annotations. Inside @Parameters annotation we have to give the name of the parameters and these names must be same as what we have given in the testng.xml as shown in the below screenshot.

Tuesday, August 7, 2018

How to execute classes in parallel in TestNG?

In the previous post How to execute test methods in parallel in TestNG? we have seen executing the test cases/test methods of a class in parallel. In this post we will learn about executing the classes in parallel. A class will contain one or more test cases/test methods.

To execute the classes in parallel, we need to set parallel = "classes" in the 'suite' tag in the testng.xml file and set thread-count = "2", this count depends on our requirement. Please check the screenshot below

Class One: In the below class 'regressionSetOne.java' we have two @test methods

Wednesday, August 1, 2018

Katalon Tutorial 07: How to find TestObject at run time in Katalon Studio?

I faced a situation where, I will be getting a dynamic xpath and I need to find the object using this xpath to perform an action it.

We know how to add the objects to object repository and use them in the test case preparation, we have seen it the previous posts.

Suppose you are working on web table, which stores the employee details row wise. And your test case is to edit the employee details.

The generic xpath of the row is "//table[@id='emp-tbl']/tbody/tr", now I need to go through all the rows one by one and if any row is matching with the given employee details then get that row number and append that row number in the generic xpath to get dynamic xpath of the row as shsho below.

Friday, July 6, 2018

How to execute test methods in parallel in TestNG?

Executing the test cases in parallel is one of the important automation feature. TestNG framework has this feature in built, we don't need to write separate code for this. Just with simple configuration in testng.xml file we can achieve the parallel execution at different levels.

We all know that the idea of having parallel execution is to reduce the execution time, with reduced execution time we can provide early feedback then we can save our efforts and money.

In this tutorial we will learn executing the test methods (test cases) in a java class file in parallel

Wednesday, July 4, 2018

How to enable or disable/ignore test methods in TestNG?

Sometimes we will be running into the situation where we need to disable/ignore some of the test cases or test methods from the execution because of various reasons like the test is failing due to known issue, the test data is not ready for the test and etc.

@Test annotation has many attributes, 'enabled' is the attribute used for disabling a test method. If we write @Test(enabled=false) for any test method in TestNG, then it will be ignored in the execution.

By default @Test() is enabled. @Test() is equivalent to @Test(enabled=true). Let us see an example on this to understand it better.

Tuesday, July 3, 2018

How to execute multiple test suites (testng.xml files) in TestNG?

We have seen In the previous post How to execute multiple test cases in TestNG? we discussed multiple ways of executing the test cases using a testng.xml (suite) file. In this post we will see executing multiple test suites in TestNG.

Generally in our projects we will be maintaining the test scripts in different test suites, say regressionSuite.xml, smokeSuite.xml.

Tuesday, May 29, 2018

BeforeMethod, AfterMethod, BeforeClass and AfterClass annotations.

TestNG provides us with number annotations to customize the test execution flow or process as per our requirement. And some of the annotations will help us to avoid code duplication and achieve code re-usability in the framework.

In this  post  we will learn about code reusability using the annotations @BeforeMethod, @AfterMethod, @BeforeClass and @AfterClass. Checkout the functionalities below.

@BeforeMethod: A method associated with this annotation will always be executed before every @Test annotated method. Application launch, Login and etc. functionalities can be put in this methods

Tuesday, April 10, 2018

Katalon Tutorial :05 How to write test cases in Manual mode in Katalon Studio?

In the Manual Mode the keywords, objects and input needs to be entered manually step by step. Please check out the video below to learn the writing the test cases in Manual Mode.


Please let me know your suggestions or comments on this topic. Thanks for reading QABABU.

#HappyLearning #QABABU

Monday, April 2, 2018

Katalon Tutorial 04: How to write test cases in Record & Playback mode in Katalon Studio?

Using Katalon Studio we can write the test cases in three scripting modes

Record & Playback: In this mode the actions on the web page are recorded using Web Recorder feature. After recording the steps are Edited/Updated to complete the test case.

Manual Mode: In this mode actions/keywords are added manually as test steps. Before adding the test steps objects should be captured added to the Object Repository.

Scripting Mode: In this mode test cases will be coded in the script editor.

Katalon Tutorial 03: Adding Objects to Object Repository using Spy Web in Katalon Studio

Object identification and object management are two important features any framework/tool. The success of any automation tool depends on the Object identification.

Katalon Studio has provided a feature called Spy Web to capture the objects from the web page. This Spy Web captures all the properties of the web object when mouse hovered and pressed Alt and twiddle keys (alt + ~).

We can select or deselect the some of the properties, based on the properties xpath will be constructed automatically.

Saturday, March 31, 2018

Katalon Tutorial 02: Installing Katalon Studio

Installing Katalon Studio is very easy, we don’t need to download any jar or driver files. We just need to download a .zip file. It is similar to eclipse IDE installation.
  • Go to https://www.katalon.com/ and click on the download button.
  • Sign up with Katalon. A recommended version will be suggested, choose 32 bit or 64 bit based on your machine and start downloading the tool.
  • Unzip the zip file and double click on the ‘katalon.exe’ to launch the IDE.
  • Then you will be asked to activate the product, enter credentials you have used while signing up. And then click on the Activate button.
  • The Katalon Studio IDE looks as below
Thanks for reading, please comment your suggestion or queries for this post.
#HappyTesting #QABABU

Advantages of Katalon Studio, Should I learn?

Katalon Studio is a free automation tool that is buitl on Selenium and Appium with amazing automation features. Katalon came up with solutions to the challenges that we have been facing with Selenium/Appium based open source automation frameworks. Some of the challenges listed below:
  • Choosing a right framework/tool based on application technology
  • Need technical experts in designing the framework
  • Need to write own code to implement features like Data Driven, Parallel Testing, Cross Browser Testing and etc.
  • Need to download or update the many Jar and Driver files
  • Locating the objects is time consuming, need to write xpaths or css selectors
  • Need to write all the Custom Keywords
  • Need to implement own reporting and logging systems

Saturday, January 20, 2018

Data Driven Testing using Scenario Outline in Cucumber

We have seen on way of Data Driven Testing in Data Driven Testing without Scenario Outline. Another way to perform Data Driven Testing in Cucumber is using 'Scenario Outline'. "Scenario Outline" is a keyword, if a test needs to be executed for more than one test data set it will be marked as "Scenario Outline" instead of "Scenario".

The only difference between 'Scenario' and 'Scenario Outline' is, 'Scenario Outline' comes along with a keyword called 'Example' using which the test data sets are represented in data table format.

Consider the same scenario which we been using in our tutorial, now let us automated the same test with different test data sets.

How to Zoom In and Zoom Out browser in Selenium?

With the help of Robot class we can Zoom In or Zoom Out the browsers in Selenium Automation. We need to press CNTRL+ADD (symbol '+') to Zoom In and CTNRL+SUBTRACT (symbol '-') to Zoom Out.

First, I tried with SendKeys() method as shown in the below screenshot for both Firefox and Chrome browsers but it didn't work. Don't know the reason but I suspect that the issue is with latest Selenium WebDriver version.


How to pass the test data from feature file?

In the example scenario 'Validate login page title' we have taken, we have not passed the test data to step definitions from feature file. The step definitions are hard coded with the test data, the browser type, url and page title as shown in the below screenshot. Hard coding never been a good programming practice.


What if we want to run the same test for different browser and application(url)? We need to write another test and different step definitions. This increases code duplication.

Monday, January 8, 2018

How to execute the Cucumber tests using Test Runner Class?

I would have combined writing feature file, writing step definitions and writing runner class in single post but it will become lengthy and may look like a complex process. So to make it simple i wrote three separate posts. Lets switch to runner class.

We have written Scenario, Steps and Step definitions. We can execute tests without test runner class also. In the previous post we have mapped (glued) Steps in feature file and Step definitions in the IntelliJ Edit Configuration. Now run the feature file 'gmailLoginFeature.feature'

You should see execution start, browser launch, application navigation and etc. But the advantage of using test runner class is you can configure reports, can add plugins, can change test behavior and etc.

Sunday, January 7, 2018

How to write the Step Definitions for the Cucumber tests?

In the previous tutorial we learned about writing the scenarios and steps in the feature file. Also we seen that steps being highlighted in yellow color since they do not have step definitions. Now we will learn writing the step definitions.

I will be taking only one scenario for simplicity. You can follow same approach for remaining scenarios.

Step 1: Create a package say 'cucumberStepsDefinion' as shown below.


Copy the path of the 'cucumberStepsDefinion' package.

How to write a Feature and Scenario using Gherkin language?

Gherkin is the language Cucumber uses to write the tests. Gherkin uses simple English words Given, When, Then, And and etc. as keywords to write the tests.

Step 1: Creating a Feature file

Create a package like 'features', right click on it --> New --> Select File. Enter the file name with '.feature' extension. And then click 'OK' button.


Saturday, January 6, 2018

Creating Maven project for Selenium Automation with Cucumber in IntelliJ IDE

Cucumber supports technologies like Java, Ruby and Php. In this tutorial we will be using Cucumber with Java. Also we will be using IntelliJ IDE because I found writing the Cucumber tests in IntelliJ is easier than writing in Eclipse. No more theory, let jump:

Pre-requisites: JDK and Maven installations.

Step 1:  Launch IntelliJ, File --> New --> Project. Select Maven project, archtype and click 'Next' button.


What are Runner Class, Feature File, Scenario and Step Definitions in Cucumber?

There are four main entities to be learned in Selenium - Cucumber automation, namely,
  • Runner Class
  • Feature Files
  • Scenarios
  • Step Definitions
Runner Class: Cucumber use Junit runner class to run the tests. It uses @RunWith junit annotation that tells Junit to run the tests as cucumber tests. Cucumber options or configuration of Feature files, Step Definitions and Reporting will also be specified in the runner class.

Friday, January 5, 2018

Introduction to Behavioral Driven Development (BDD)

Behavioral Driven Development (BDD) is one of the most echoing buzz word in the current software industry. It is a software development methodology, that is used to address the common problems or challenges faced in traditional software development methodologies TDD or ATDD.

Thursday, January 4, 2018

Headless Automation Testing using Selenium and PhantomJS.

In the previous post How does Headless Testing helps in Software Testing? we have seen the advantages of Headless testing of a software. In this post we will learn executing a test case using headless browser.

There are different tools available for carrying out the headless testing some are listed below:
  • HtmlUnitDriver
  • PanthonJS
  • Nightmare
  • Headless Chrome
We will be focusing on headless testing using Selenium and PanthomJS. PanthomJS is a webkit which runs headless with an inbuilt JavaScript API. It has fast and native support for various web standards such as DOM handling, CSS selector and JSON.

Wednesday, January 3, 2018

How does Headless Testing helps in Software Testing?

Headless Browser is a browser with no Graphical User Interface (GUI). User will not see any application visuals everything runs in background. Headless browsers are faster than real browsers because they bypass the time taken by real browser to load Objects, JavaScript and to render HTML. So if performance is critical agenda, one should go for headless browser. 

Headless Browser Testing:

Headless Browser Testing is a way of running the your tests without GUI or Application or Browser launch. One main reason for choosing the Headless Testing is performance. Where tests will be running in the background with no UI and which makes the tests run much quicker than in traditional browser testing.

DevOps 01: What is DevOps and How it benefits organizations?

DevOps is a culture in an organization, where the development team and operations team help each other by sharing information, process and t...