Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

selectWindow cannot find window using javascript variable in Firefox #3270

Closed
lukeis opened this issue Mar 3, 2016 · 4 comments
Closed

selectWindow cannot find window using javascript variable in Firefox #3270

lukeis opened this issue Mar 3, 2016 · 4 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 3270

When I try to select a window using selectWindow like so:

    selenium.selectWindow("var=popupWindowVar");

I get an error stating that the window cannot be found. I set the javascript variable
like so

    window.popupWindowVar = window.open("popup.html", "popupWindowID");

Here's the stats

Selenium version: 2.17
OS: Windows 7
Browser: Firefox 9.0.1

Here is a sample test case. I've attached the Java test case, and the "index.html"
and "popup.html" that I use in the test.

///////////////////////////////////////////

package org.example;

import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;

import com.thoughtworks.selenium.DefaultSelenium;

public class SeleniumIntegrationTest {
    private static SeleniumServer server = null;
    private DefaultSelenium selenium = null;


    @BeforeClass
    public static void oneTimeSetUp() throws Exception {
        // Create a configuration to override defaults.
        RemoteControlConfiguration rcc = new RemoteControlConfiguration();
        rcc.setTimeoutInSeconds(60);
        rcc.setPort(4444);
        rcc.setSingleWindow(true); // Support Popups
        rcc.setTrustAllSSLCertificates(true); // Trust SSL

        // Start the Selenium Server.
        server = new SeleniumServer(false, rcc);
        server.start();
    }

    @AfterClass
    public static void oneTimeTearDown() throws Exception  {
        server.stop();
    }

    @Before
    public void setUp() throws Exception {
        // Create a Selenium thread.
        // Open in Firefox
        selenium = new DefaultSelenium("localhost", 4444,
                "*firefox3",
                "http://localhost:8080/");

        selenium.start();
    }

    @After
    public void tearDown() {
        // Stop the Selenium thread.
        selenium.stop();
    }

    @Test
    public void popupWindowExample() {
        // Open the base window.
        selenium.open("index.html");
        assertEquals(selenium.getTitle(), "Popup Window Example");

        // Click button to popup new window.
        selenium.click("id=popupButton");
        // Select the popup window.
        // popupWindowID is the ID given in the window.open javascript.
        selenium.waitForPopUp("popupWindowID", "30000");
        selenium.selectWindow("name=popupWindowID");
        assertEquals(selenium.getTitle(), "Popped Up Window");

        // Click a link to google on the popup.
        selenium.click("link=This link goes to google");
        selenium.waitForPageToLoad("30000");
        assertEquals(selenium.getTitle(), "Google");

        // Select the original window.
        selenium.selectWindow("null");
        assertEquals(selenium.getTitle(), "Popup Window Example");

        // Select the window by a javascript variable.
        // THIS FAILS IN FIREFOX!!!
        selenium.selectWindow("var=popupWindowVar");
        assertEquals(selenium.getTitle(), "Google");
    }

}



Reported by tony.zampogna on 2012-01-25 03:07:39


- _Attachment: [SeleniumIntegrationTest.java](https://storage.googleapis.com/google-code-attachments/selenium/issue-3270/comment-0/SeleniumIntegrationTest.java)_ - _Attachment: [index.html](https://storage.googleapis.com/google-code-attachments/selenium/issue-3270/comment-0/index.html)_ - _Attachment: [popup.html](https://storage.googleapis.com/google-code-attachments/selenium/issue-3270/comment-0/popup.html)_
@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by barancev on 2012-01-26 09:14:47

  • Labels added: Component-RC

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Try switching by the window name.

Also, all active development is focused on WebDriver, not Selenium RC, so I'm lowering
this bug's priority accordingly.

Reported by jmleyba on 2012-01-27 18:26:45

  • Labels added: Priority-Low
  • Labels removed: Priority-Medium

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This issue was closed by revision 2b34cc2d9f00.

Reported by barancev on 2013-10-28 18:16:30

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:14:38

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant