1

我正在使用最新的 Selenium IDE 2.2.0,

我在尝试访问我在脚本中设置的 javascript 全局变量时遇到了麻烦。

这个变量充当成功标志,所以我把

Command: waitForCondition
Target: test
Value: 2000

但我明白了

[error] test is not defined

我试过用 Selenium IDE 查看 Access JavaScript 变量,替换

Target: this.browserbot.getUserWindow().test

但我也得到

[error] this.browserbot is undefined

我可以尝试另一种设置成功标志的方法,比如发出警报,但我想知道如何访问我的 javascript 变量。

文档提到了storedVars,但这仅适用于存储在硒中的变量,所以我束手无策。

4

1 回答 1

0

我环顾四周,发现以下文档

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

作品!

于 2013-07-31T15:06:29.790 回答