我正在使用最新的 Selenium IDE 2.2.0,
我在尝试访问我在脚本中设置的 javascript 全局变量时遇到了问题。
这个变量作为一个成功标志,所以我把
Command: waitForCondition
Target: test
Value: 2000
但是我明白了
[error] test is not defined
我试过查看 Access JavaScript variables with Selenium IDE , 替换
Target: this.browserbot.getUserWindow().test
但我也明白了
[error] this.browserbot is undefined
我可以尝试另一种设置成功标志的方法,例如发出警报,但我想知道如何访问我的 javascript 变量。
文档中提到了 storedVars,但这仅适用于存储在 selenium 中的变量,所以我束手无策。
最佳答案
我环顾四周,找到了以下文档
Command: waitForEval
Note that, by default, the snippet will run in the context of the "selenium" object
itself, so this will refer to the Selenium object. Use window to refer to the window
of your application, e.g. window.document.getElementById('foo')
If you need to use a locator to refer to a single element in your application page,
you can use this.browserbot.findElement("id=foo") where "id=foo" is your locator.
等等
window.test
有效!
关于javascript - 从 Selenium IDE 访问 Javascript 全局变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17970150/