简体   繁体   中英

FireFox Selenium IDE, executing JavaScript snippets with the browser 'window' context, not the Selenium window

When the browser is out of focus, focus and blue events do not get triggered properly. http://makandracards.com/makandra/12661-how-to-solve-selenium-focus-issues - this article suggests triggering the events explicitly through JavaScript, but whenever I try executing any script, 'window' always refers to Selenium IDE window which is completely pointless in my eye. I want the context of the actual browser window where the test is running.

For injecting JavaScript,it's got to include window and document:

window.document.getElementById('elementid');

Taken from function description in selenium IDE:

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, eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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