javascript/selenium:从文档对象获取窗口
我正在为selenium编写用户扩展。我有javascript/selenium:从文档对象获取窗口,javascript,firefox,dom,selenium,document,Javascript,Firefox,Dom,Selenium,Document,我正在为selenium编写用户扩展。我有文档对象。如何获取包含文档的窗口的窗口对象 PageBot.prototype.locateElementByMyLocator= function(text, inDocument) { // I want the window here } 在IE的document.parentWindow中;在Mozilla中,它是document.defaultView 因此,你可以做一些类似的事情 function getDocWindow(doc
文档
对象。如何获取包含文档的窗口的窗口
对象
PageBot.prototype.locateElementByMyLocator= function(text, inDocument) {
// I want the window here
}
在IE的document.parentWindow中;在Mozilla中,它是document.defaultView 因此,你可以做一些类似的事情
function getDocWindow(doc) {
return doc.parentWindow || doc.defaultView;
}
如果您正在编写自己的扩展,您可以通过
Selenium.prototype.doExtensionStuff(){
var doc = this.browserbot.getUserWindow().document; //This returns the document that Selenium is using
}
这被认为是一种更好的方法,并且可以在任何浏览器上使用,因为Selenium会处理不同的浏览器问题首先是如何获得文档对象的?在测试运行期间,我似乎无法获取它。。。