Skip to main content

Cucumber Language Support

English is the third most spoken native language in the world, after Standard Chinese and Spanish. It is the most widely learned second language and is either the official language or one of the official languages in almost 60 sovereign states.

Support is provided for other languages in Cucumber so that stakeholders can express themselves in language they are comfortable with. You can write your Gherkin Feature file in 74 Languages.

Consider multilingual website which exist in different languages and you have to assert elements in that language only. In that case you would need support for other languages than English.

In a single project, we can have Feature files in multiple languages; but for one Feature file, only one language will work.

For step definition, no languages configuration or settings are required.

Feature file in English

@search
Feature: Search
  I want to search the website

  Background:
  Given I am on the homepage

  @smoke
  Scenario: Keyword Search
    When I fill "search textbox" with "dress"
    Then I click "search button"

Same Feature file in French

# language: fr
@chercher
Fonctionnalité: Chercher
  Je veux chercher sur le site

  Contexte:
  Étant donné que je suis sur la page d'accueil

  @smoke
  Scénario: Recherche par mot clé
    Quand je remplis "champ de recherche" avec "robe"
    Alors Je clique "bouton de recherche"

Step Definition For above Feature file


@Étantdonnéque("^je suis sur la page d'accueil$")
public void je_suis_sur_la_page_d_accueil() 
{

}

@Quand("^je remplis \"([^\"]*)\" avec \"([^\"]*)\"$")
public void je_remplis_avec(String arg1, String arg2)
{

}

@Alors("^Je clique \"([^\"]*)\"$")
public void je_clique(String arg1) 
{

}

Link for all supported Languages and Keywords: Gherkin Dialect

Submitted by tgoswami on August 30, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.