History | Log In     View a printable version of the current page.  
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
Component/s: BrowserBot-Mozilla
Affects Version/s: 0.8.2
Fix Version/s: 1.0

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
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


 All   Comments   Work Log   Change History      Sort Order:
Zackary Geers - 24/Apr/07 01:52 PM
I've expierenced this exact issue, and I would like to see it resolved because the error message doesn't lead you to what the actual problem is.
This is also a dupe of issue 234

Zackary Geers - 24/Apr/07 01:55 PM
Edit: This is also a dupe of SRC-234

Dan Fabulich - 03/Jul/07 12:20 AM
This looks pretty straightforward, but someone will need to add a working HTML test for it. (e.g. add _self to test_bottom.html and update TestFramesSpecialTargets.html.)

If someone can provide a test before 0.8.3 goes out, I'll target this for 0.8.3; otherwise, it'll be in 0.8.4.

Dan Fabulich - 25/Oct/07 04:15 PM
core revision 2065