我正在为用户扩展selenium。我有document
对象。如何获取包含我的文档的窗口的window
对象?javascript/selenium:从文档对象中获取窗口
PageBot.prototype.locateElementByMyLocator= function(text, inDocument) {
// I want the window here
}
我正在为用户扩展selenium。我有document
对象。如何获取包含我的文档的窗口的window
对象?javascript/selenium:从文档对象中获取窗口
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正在照顾不同浏览器的不良之处
您是如何获得文档对象的?我似乎无法在测试运行中取回它... – 2014-09-17 15:14:16