我正在使用 Selenium Fitnesse Bridge Fixture 来编写测试版Fitnesse for Selenium。这很棒,因为它涵盖了Selenium所具有的 ALL 功能。但是,我遇到的问题是存储变量,就像我在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} |  |

这个简单的东西应该可以正常工作,但是当我保存测试时,我得到一个错误,未定义的变量。

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

这没有意义。我在回声之前定义了变量。当我进行测试时,我得到:

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

作者正在使用他的测试做同样的事情。为什么这对我不起作用?

有帮助吗?

解决方案

问题在于Fitnesse感到困惑。它认为你没有定义一个变量。

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

绕过Fitnesse的困惑的方法是通过围绕变量名来逃避变量名! - - !。

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

现在这将回应所需的回应。

| !- 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 |
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top