Issue Details (XML | Word | Printable)

Key: SEL-417
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Craig
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Selenium

ahref target attr value _self produces a Window does not exist Error

Created: 04/Jan/07 09:42 AM   Updated: 05/Feb/08 04:37 PM   Resolved: 25/Oct/07 04:15 PM
Return to search
Component/s: BrowserBot-Mozilla
Affects Version/s: 0.8.2
Fix Version/s: 1.0

Environment: firefox 1.5.0.9


 Description  « Hide

If a link (ahref) has a target attribute and that target attribute's value is "_self", you get a "Window does not exist" Error when the command clickAndWait is run. After some research I modified the selenium-browserbot.js file in the method getWindowByName. I added the follow to the code

else if (!targetWindow && windowName == "_self"){ targetWindow = this.topWindow; }

So the whole method now looks like this

BrowserBot.prototype.getWindowByName = function(windowName, doNotModify) {
LOG.debug("getWindowByName(" + windowName + ")");
// First look in the map of opened windows
var targetWindow = this.openedWindows[windowName];
if (!targetWindow) { targetWindow = this.topWindow[windowName]; }
if (!targetWindow && windowName == "_blank") {
for (var winName in this.openedWindows) {
// _blank can match selenium_blank*, if it looks like it's OK (valid href, not closed)
if (/^selenium_blank/.test(winName)) {
targetWindow = this.openedWindows[winName];
var ok;
try {
if (!this._windowClosed(targetWindow)) { ok = targetWindow.location.href; }
} catch (e) {}
if (ok) break;
}
}
}
else if (!targetWindow && windowName == "_self"){ targetWindow = this.topWindow; } }
if (!targetWindow) { throw new SeleniumError("Window does not exist"); }
if (browserVersion.isHTA) {
try { targetWindow.location.href; } catch (e) { targetWindow = window.open("", targetWindow.name); this.openedWindows[targetWindow.name] = targetWindow; }
}
if (!doNotModify) { this._modifyWindow(targetWindow); }
return targetWindow;
};

I think this is the right thing to do, but am not 100% sure, it fixed my problem.

So to sum up if I see a target="_self" I set targetWindow to this.topWindow.

Craig



Sort Order: Ascending order - Click to sort in descending order
Dan Fabulich made changes - 03/Jul/07 12:20 AM
Field Original Value New Value
Fix Version/s 0.8.4 [ 10480 ]
Dan Fabulich made changes - 25/Oct/07 04:15 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Dan Fabulich made changes - 05/Feb/08 04:37 PM
Status Resolved [ 5 ] Closed [ 6 ]