繁体   English   中英

从Selenium IDE访问Javascript全局变量

[英]Accessing Javascript global variables from Selenium IDE

我正在使用最新的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,但这仅适用于存储在硒中的变量,因此我处于机智。

我四处张望,发现以下文档

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

作品!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM