
| Key: |
SEL-417
|
| Type: |
Bug
|
| Status: |
Closed
|
| Resolution: |
Fixed
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
Craig
|
| Votes: |
1
|
| Watchers: |
0
|
|
If you were logged in you would be able to see more operations.
|
|
|
|
Original Estimate:
|
Unknown
|
Remaining Estimate:
|
Unknown
|
Time Spent:
|
Unknown
|
|
Environment:
|
firefox 1.5.0.9
|
|
|
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
|
|
Description
|
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
|
Show » |
|
This is also a dupe of issue 234