2013-07-31 144 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 

作品!