radish-bdd / radish

Behavior Driven Development tooling for Python. The root from red to green.
https://radish-bdd.github.io
MIT License
182 stars 49 forks source link

Is it possible to provide Data inside a Feature for all Scenarios ? #398

Closed dschiller closed 4 years ago

dschiller commented 4 years ago

The Feature

Feature: Login Form Labels use correct Language

    The Controls on the Login Form are used in the correct Languages

    Scenario Outline: Check if the `Email` Textbox Label Language is correct

        Open URL "http://test1/webmo"
        Set Language "<Language>"
        Textbox "email" Label is "<Value>"

        Examples:
        |Language|Value                                 |
        |de      |E-Mail- oder Anmeldename              |
        |en      |Email or Login Name                   |
        |fr      |Email ou nom de connexion             |
        |it      |Email o Nome di accesso               |
        |nl      |E-mail of loginnaam                   |
        |fi      |Sähköpostiosoite tai kirjautumistunnus|

    Scenario Outline: Check if the `Password` Textbox Label Language is correct

        Open URL "http://test1/webmo"
        Set Language "<Language>"
        Textbox "password" Label is "<Value>"

        Examples:
        |Language|Value          |
        |de      |Passwort       |
        |en      |Password       |
        |fr      |Mot de passe   |
        |it      |Parola d'ordine|
        |nl      |Wachtwoord     |
        |fi      |Salasana       |

    Scenario Outline: Check if the `Register` Button Label Language is correct

        Open URL "http://test1/webmo"
        Set Language "<Language>"
        Button "register" Label is "<Value>"

        Examples:
        |Language|Value       |
        |de      |Registrieren|
        |en      |Register    |
        |fr      |S'inscrire  |
        |it      |Registrati  |
        |nl      |Registreren |
        |fi      |Rekisteröidy|

Is it possible to set a Feature Variable which holds the http://test1/webmo Value which I then can pass to all Scenarios ?

fliiiix commented 4 years ago

I don't think this is possible. And I think the way to approach this is to write self containing Scenarios something like this:

Open URL "http://test1/webmo"
Set Language "<Language>"
Textbox "email" Label is "<Email>"
Textbox "password" Label is "<Password>"

Examples:
|Language|Email                                 |Password |
|de      |E-Mail- oder Anmeldename              |Passwort |
dschiller commented 4 years ago

Yes, sure. Thank you a lot!

fliiiix commented 4 years ago

I think it would be possible to share data over the world object https://radish.readthedocs.io/en/stable/tutorial.html#world

BUT that is absolutely not recommend

Maybe using before.each_feature would be a option for you https://radish.readthedocs.io/en/stable/tutorial.html#terrain-and-hooks if you don't care about the visibility of the URL in your test which I'm personally not a fan of.

edaine commented 4 years ago

You can use Constants: https://radish.readthedocs.io/en/stable/tutorial.html#constants