2013-07-31 147 views
1

我使用的是最新的硒IDE 2.2.0,访问的JavaScript硒IDE全局变量

,我有麻烦试图访问一个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,但是这只适用于存储在硒中的变量,所以我在我的智慧的结尾。

回答

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 

作品!