Currently Browsing

Automated Testing Tools

Cucumber in Web testing (part 2 of 8)

2. How to install cucumber in Eclipse

To start using cucumber in eclipse we need to install few things:

  1. First of all eclipse and Java Development Kit (JDK) need to be installed on the computer.
  2. Ones eclipse finished with the installation we are able to install “Cucumber Eclipse Plugin” with eclipse built-in plugin installation tool. Step by step instructions can be found here.
  3. Download cucumber libraries. Multiple solution can be found here. We recommend to use Maven to download and manage all dependencies.

Our pom.xml contains the following dependencies:

Cucumber in Web testing (part 1 of 8)

1. What is cucumber

Cucumber is a testing framework which supports behavior-driven development (BDD). BDD is principally an idea about how software development should be managed by both business interests and technical insight. Implementation of BDD starts with describing the test cases with English like sentences following up with the test case implementation. With this we will have implemented test cases plus detailed test documentation also, which can be really handy at enormous number of test cases.

Cucumber testing framework uses Gherkin DSL to define test cases. The language itself is designed to be non-technical and human readable which enables the whole development team to have insight into the test cases including business analysts and managers also.

What is the best site or where to find quality material for learning?

New Year. New Resolution(s). If you haven’t started yet to work on new skills, it is the right period to do it. (it is never late anyway, but sooner is better)
Some holidays are over, some will just arrive. You have already started thinking about “upgrade” yourself to a “bigger”, smarter, more valuable you. Good thinking.

But, the most important question is where to start?

Browsing through the internet you can find a dozen of quality materials. But how can I know where could I learn the most and spend much less time with it?
The question will never have an exact answer because it always depends only on you. You can find quality materials, with the best ratings (actually, those are definitely worth to try), but it will not guarantee that it will fit for you.

So, where to find it?

If you already found earlier some lecturers, presenters, teachers who had shown nice approach to you, by explaining and presenting the materials, follow them. Search for their further work. That will surely spare you from some headache and from spending too much time for searching. Also, if there is one, there will be more. Investigate, listen and watch other ones.
What If I don’t want to spend too much money or I don’t want to spend money at all to those materials?
There are always individuals, who will catch your attention, and just from fun started to share their materials to help anyone who has the will to learn more. You have then three solutions.

Lambda expressions in java 8

One of the key elements of the functional programing is that we can treat functions as objects. In a typical functional language we can have a variable with type of function. The benefits are that we can use functions as:

  • • parameter
  • • return type
  • • variable

The type Function in Java is interface with one abstract method. If we want to be sure that an interface can be used as a function type we can add annotation @FunctionalInterface before the header of the interface. It will throw compilation error if the interface contains more then one abstract method.

If a method has a parameter with function type we can use lambda expression instead of creating an anonymous class. Lambda expression represents an anonymous class in a shorter and readable way. Lambda expression consists from parameter definition, small right arrow “->”, and the body of the method.

Benefits of using default methods in interfaces (JDK8) in web testing with selenium

Programming language Java doesn’t allow multiple inheritances. Java uses interfaces to simulate multiple inheritances without importing its disadvantages. The cost of this is that method implementation was not possible in interfaces until JDK 8.

JDK 8 contains a new feature which allows us to create default implementation for interface methods. Simply just add keyword “default” before the method definition and add implementation body for it. With this, the method will have a default implementation and we don’t need to override them anymore. Basically, we went a step toward multiple inheritances.

As always, there are few disadvantages which came with this feature. We will get a compile error if we have multiple default implementation for the same method. It can be fixed by overriding the method with a new implementation or explicitly call the chosen default method.

Secure use of sendKeys() on pages created with Angular

We recently faced with an Selenium’s sendKeys() method issue which is related to the page which was made in Angular 1.5.8 (Most likely the same issue can be discovered in different versions). In most of the cases, the input field filled by sendKeys() method will contain just part of the desired text. Most often you will find just the first half of you desired text written into the input field. From our experience this bug appears only in the following circumstances:

  1. Page must be made with Angular
  2. The input field must be tagged with angular attributes, like ngModel, ngControl, etc.

Read out browser console logs in java with selenium 2.53.1

Sometimes the usual test log and screenshot is not enough to find the reason of the failed test case. Especially when the test case occasionally fails in special circumstances and it is really hard to reproduce. For this reason, we need to collect for each fail as much information as possible. One possible source of information is the console output of the browser.

Behat Mink default commands in Gherkin

The Gherkin language provide us with lot of ambiguous commands that help us write steps faster and code less.
Beside the default steps you can always add your own steps and write background code for additional re-usability and handling. More about this on later blog following the Behat BDD development.

To list out the default commands use command “bin/behat -dl” and you should get result like:

Behat test examples – BDD and PHP

Continuing on my previous post about setting up a Behat test environment on Windows 10 now we will create some tests to see how the setup is working. These are some basic tests, as we are learning together.For running test we need to create a “behat.yml” file which Behat use as configuration file by default. more about it on this link: http://docs.behat.org/en/v3.0/user_guide/configuration.html#behat-yml

You can also find some example files on the web.
My experimenting config file contains values sufficient for some first basic tests:

default:
  extensions:
    Behat\MinkExtension:
      base_url: 'http://wedoqa.com/'
      browser_name: chrome
      goutte: ~
      selenium2: ~
paths:
    features: features
    bootstrap: %behat.paths.features%/Context

This configuration will:
– use http://wedoqa.com/ as base page to load on start,
– run tests in chrome (if browser is required),
– use goutte and selenium2 basic configurations,
– setup paths for Features and FratureContext.

Third-party program doesn’t allow hibernate session to close

We had an issue with hibernate connections failed to close. We used separated connections for each Dao and all of them stayed open even we called session.close() in after method for each used Dao and checked that they were really executed. The connections have died 2h after the test run, for each test we left open 5-10 connection and because the connection limit to the DB was really small (100 connection) we were unable to run tests as often as we wished.
Useful information about connection kill can be found here.