How to get Window ID

3,193 views
Skip to first unread message

newtosel

unread,
Nov 3, 2006, 4:59:15 AM11/3/06
to selenium-users...@googlegroups.com
There are certain commands which requires windowID.
For ex:SelectWindow,waitForPopUp.....

Now,how to get the window ID?

is this notheing but window title?

Nelson Sproul

unread,
Nov 3, 2006, 11:53:17 AM11/3/06
to selenium-users...@googlegroups.com
It's not the window title. I will probably implement getAllSelectableWindowIds() to make it easier to see what tokens you can use to select a window.

Look at the doc for selectWindow for an explanation (available to you in the doc system of your language, e.g., javadoc for Java):

Selects a popup window; once a popup window has been selected, all
commands go to that window. To select the main window again, use null
as the target.

Selenium has several strategies for finding the window object referred to by the "windowID" parameter.

1.) if windowID is null, then it is assumed the user is referring to the original window instantiated by the browser).
2.) if the value of the "windowID" parameter is a JavaScript variable name in the current application window, then it is assumed
that this variable contains the return value from a call to the JavaScript window.open() method.
3.) Otherwise, selenium looks in a hash it maintains that maps string names to window objects. Each of these string
names matches the second parameter "windowName" past to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag)
(which selenium intercepts).

If you're having trouble figuring out what is the name of a window that you want to manipulate, look at the selenium log messages
which identify the names of windows created via window.open (and therefore intercepted by selenium). You will see messages
like the following for each window as it is opened:

{code:html}<code>debug: window.open call intercepted; window ID (which you can use with selectWindow()) is "myNewWindow"</code>{code}

In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example).
(This is bug SEL-339.) In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
an empty (blank) url, like this: openWindow("", "myFunnyWindow").

@param windowID the JavaScript window ID of the window to select

newtosel

unread,
Nov 6, 2006, 5:22:51 AM11/6/06
to selenium-users...@googlegroups.com
Thanks for this.

It worked for me.

Reply all
Reply to author
Forward
0 new messages