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...