xebia / Xebium

Xebium provides Selenium (webdriver) bindings for FitNesse, with Selenium-IDE support
http://xebia.github.com/Xebium/
Apache License 2.0
76 stars 62 forks source link

How to define variables for scenarios on a test page? #160

Open pmmvr opened 8 years ago

pmmvr commented 8 years ago

Hi,

I have a number of generic test scenarios that contain variables. I now want to combine these scenarios in test pages to create user stories. The definition of the variables will be different in each test page.

When I define the variables in the ScenarioLibrary page it works flawless. However, when I define the variables in a test page and create a script combining a number of scenarios, Fitnesse is unable to grab the definition of the variables...

I am aware it's possible to use variables by placing a variable name after the scenario logical name, calling the variable in the scenario and then defining this variable again in the test page. Like this in ScenarioLibrary

| scenario | add product | productname |
| ensure | do | sendKeys | on | id=product_name | @productname|

and this in the test page

!define productname {iPad}

|script|
|add product | $productname|

but this seems to work only for 1 variable ...

Does anyone have a tip or a work-around to get this working?

Thanks.

cwortel commented 8 years ago

Hey,

I actually have created an issue in the Fitnesse project for a similar issue. The variables are not picked up by scenario's in a library that is higher in the project structure. The issue has not been solved, because the Fitnesse team at that point was scared it would somehow result in compatibility problems with exiting users.

I can't remember quite how I worked around it.

One question, is the idea you're aiming to reuse identical test pages with a variaty of different products? In other words, what is the exact need for the use of variables here. If you do not want to reuse the entire test page, this would be the way to use your scenario.

|script| |add product | ipad |

For my initial issue:

https://github.com/unclebob/fitnesse/issues/37

On Mon, Mar 7, 2016 at 2:47 PM, pmmvr notifications@github.com wrote:

Hi,

I have a number of generic test scenarios that contain variables. I now want to combine these scenarios in test pages to create user stories. The definition of the variables will be different in each test page.

When I define the variables in the ScenarioLibrary page it works flawless. However, when I define the variables in a test page and create a script combining a number of scenarios, Fitnesse is unable to grab the definition of the variables...

I am aware it's possible to use variables by placing a variable name after the scenario logical name, calling the variable in the scenario and then defining this variable again in the test page. Like this in ScenarioLibrary

| scenario | add product | productname | | ensure | do | sendKeys | on | id=product_name | @productname|

and this in the test page

!define productname {iPad}

|script| |add product | $productname|

but this seems to work only for 1 variable ...

Does anyone have a tip or a work-around to get this working?

Thanks.

— Reply to this email directly or view it on GitHub https://github.com/xebia/Xebium/issues/160.

pmmvr commented 8 years ago

Hi,

Thanks for your answer. I found a workaround.

In my OP i wrote:

but this seems to work only for 1 variable ...

Which was a wrong and premature assumption on my side. I found out that each variable in the scenario title needs a preceding descriptor in order to work. So my current workaround is to add all variables in the relevant scenario in the Scenario Library, so you get this:

|Scenario| Add new product | PRODUCT| with color | COLOR | and memory| MEMORY |
| ensure | do | type | on | id=name| with | @PRODUCT |
| ensure | do | select| on | id=colortype | with | lablel=@COLOR |
| ensure | do | select | on | id=gb-memory| with | label=@MEMORY |

In the test page I add the following variables:

!define PRODUCT {iPAD}
!define COLOR  {Space Grey}
!define MEMORY {16gb}

And the sript as:

|script|
| Add new product | ${PRODUCT}| with color | ${COLOR} | and memory| ${MEMORY} |

Which results in:

|script|
| Add new product | iPad | with color | Space Grey | and memory| 16gb |

So now i can create different test-pages for different products or simply change the variables on the test page accordingly to quickly run new tests. This is working perfectly so far and gives the business a clear idea of what is being tested.

cwortel commented 8 years ago

excellent ;)

On Wed, Mar 9, 2016 at 10:33 AM, pmmvr notifications@github.com wrote:

Hi,

Thanks for your answer. I found a workaround.

In my OP i wrote:

but this seems to work only for 1 variable ... Which was a wrong and premature assumption on my side. I found out that each variable in the scenario title needs a preceding descriptor in order to work. So my current workaround is to add all variables in the relevant scenario in the Scenario Library, so you get this:

|Scenario| Add new product | PRODUCT| with color | COLOR | and memory| MEMORY | | ensure | do | type | on | id=name| with | @PRODUCT | | ensure | do | select| on | id=colortype | with | lablel=@COLOR | | ensure | do | select | on | id=gb-memory| with | label=@MEMORY |

In the test page I add the following variables:

!define PRODUCT {iPAD} !define COLOR {Space Grey} !define MEMORY {16gb}

And the sript as: |script| | Add new product | ${PRODUCT}| with color | ${COLOR} | and memory| ${MEMORY} |

Which is working for now.

— Reply to this email directly or view it on GitHub https://github.com/xebia/Xebium/issues/160#issuecomment-194207024.