使用Selenium IDE访问JavaScript变量

Fil*_*vić 8 javascript selenium

我想知道是否可以使用Selenium访问页面JavaScript变量.我有一个应用程序正在使用附加到窗口对象的变量.它有一个全球范围内,我可以与访问它window._myvar,window['_myvar'],_myvar,this['_myvar'],this._myvar要看具体情况.

所以我试图让Selenium回应它.据我所知,在Selenium IDE中,一切运行的环境都是selenium.我试过了this.browserbot.getCurrentWindow()._myvar,this.browserbot.getCurrentWindow()[_myvar]无济于事.我遇到了以下错误Unexpected Exception: message -> eval(match[1]) is undefined.

有人设法访问他们网页的JavaScript吗?

Dav*_*unt 17

您应该能够使用getUserWindow而不是getCurrentWindow来获取变量.请参阅以下示例:

assertEval | this.browserbot.getUserWindow().myVar | Hello World!
Run Code Online (Sandbox Code Playgroud)