views:

2150

answers:

1

I'm using the Selenium Fitnesse Bridge Fixture in order to write tests in Fitnesse for Selenium. It's great because it covers ALL the functions that Selenium has. However, the problem I'm running into is storing variables like I would in Selenium IDE.

| !- fixtures.SeleniumFixture -!|
| setup | http://www.google.com/ | *chrome /usr/lib/firefox-3.0.5/firefox |
| open | http://www.google.com/ |  |
| storeLocation | here | |
| echo | ${here} |  |

Something as simple as this should work just fine, but when I save the test I get an error, undefined variable.

| storeLocation | here |  |
| echo | undefined variable: here |  |

This just doesn't make sense. I'm defining the variable the line before I echo it. When I run the test, I get:

| storeLocation | here |  |
| echo | undefined variable: here | undefined variable: here |

The author is doing the same sort of thing with his tests. Why won't this work for me?

A: 

The problem is that Fitnesse is getting confused. It thinks that you are not defining a variable.

!define variable {variable}
| echo | ${variable} |  |

The way to get around Fitnesse's confusion is to escape the variable name by surrounding it with !- -!.

| storeLocation | here | |
| echo | ${!-here-!} |  |

This will now echo the desired response.

| !- fixtures.SeleniumFixture -!|
| setup | http://www.google.com/ | *chrome /usr/lib/firefox-3.0.5/firefox |
| open | http://www.google.com/ |  |
| storeLocation | here | |
| echo | ${here} | http://www.google.com |
Andrew