我们如何在 Fitnesse 中使用 javascript 变量?
我正在尝试将 JavaScript 函数中的值传递到 Fitnesse 页面。我使用语法“!define {default_value}”在 Fitnesse 页面中定义了一个变量。但我想从 Java 脚本将值分配给这个变量。有什么方法可以将值从 javascript 传递到fitnesse 变量吗?
I am trying to pass a value from a function of JavaScript to Fitnesse page. I have defined a variable in Fitnesse page using syntax " !define {default_value} ". But I want to assign the value to this variable from Java script. Is there any way we can pass the value from javascript to fitnesse variable??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是最近另一位 FitNesse 用户提出的。据我了解 FitNesse,这是行不通的。 FitNesse 运行测试页面的方式,实际上并不使用您在运行测试时看到的页面。当您单击“测试”按钮时,会发生以下情况:
当您单击“测试”按钮时,它是就像您在浏览器中输入以下 URL 一样:
因此,FitNesse 对浏览器中页面的状态一无所知。
最近有一项提议允许将属性作为 URL 的一部分进行传递,然后可以通过 ${property} 变量引用来呈现。
此外,对于其如何运作还有其他考虑因素。问题之一是当您将测试作为套件的一部分运行时,您将如何设置下拉列表。
执行此操作的最佳方法可能是确保该下拉列表中的每个选项都有测试页面。我推荐这样做是因为它们可能会产生不同的结果,或者为什么它们很重要?
另一种方法是为您要测试的内容创建一个场景,然后使用每个值调用该场景。
归根结底,你想做的事情并不是 FitNesse 擅长的。
This has come up recently from another FitNesse user. As I understand FitNesse, this won't work. The way that FitNesse runs the test page, it doesn't actually use the page that you see when it runs the test. When you click on the test button, the following happens:
When you click on the Test button, it is the same as if you had typed in the following URL in the browser:
As such, FitNesse doesn't know anything about the state of the page in the browser.
There has been a recent proposal of allowing the passing of properties as a part of the URL that could then be rendered by a ${property} variable reference.
Additionally, there are other considerations for how this would work. One of the issues is when you run a test as a part of a suite, how would you set your drop down.
The best way to do this is probably to make sure you have either test pages for each option in that drop-down. I recommend this because presumably they produce different results, or why would they matter?
The other way to do this would be to create a scenario for what you want to test and then call that scenario with each value.
Ultimately, the thing you want to do isn't something that FitNesse is good at.