我正在爲用戶擴展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