in reply to Searching for a window using www::selenium

If I read the documentation for WWW::Selenium correctly, $sel->select_window() needs additional help to determine the appropriate window:

<quote>

$sel->select_window($window_id) Selects a popup window using a window locator; once a popup window + has been selected, all commands go to that window. To select the mai +n window again, use null as the target. Window locators provide diffe +rent ways of specifying the window object:by title, by internal JavaS +cript "name," or by JavaScript variable. * title=My Special Window:Finds the window using the text that + appears in the title bar. Be careful;two windows can share the same +title. If that happens, this locator willjust pick one. * name=myWindow:Finds the window using its internal JavaScript + "name" property. This is the second parameter "windowName" passed to + the JavaScript method window.open(url, windowName, windowFeatures, r +eplaceFlag)(which Selenium intercepts). * var=variableName:Some pop-up windows are unnamed (anonymous) +, but are associated with a JavaScript variable name in the current a +pplication window, e.g. "window.foo = window.open(url);". In those ca +ses, you can open the window using"var=foo". If no window locator prefix is provided, we'll try to guess what y +ou mean like this: 1.) if windowID is null, (or the string "null") then it is assumed + the user is referring to the original window instantiated by the bro +wser). 2.) if the value of the "windowID" parameter is a JavaScript varia +ble name in the current application window, then it is assumed that t +his 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 str +ing names to window "names". 4.) If that fails, we'll try looping over all of the known windows + to try to find the appropriate "title".Since "title" is not necessar +ily unique, this may have unexpected behavior. If you're having trouble figuring out the name of a window that yo +u want to manipulate, look at the Selenium log messages which identif +y the names of windows created via window.open (and therefore interce +pted by Selenium). You will see messages like the following for each + window as it is opened: debug: window.open call intercepted; window ID (which you can use with + selectWindow()) is "myNewWindow"
</quote>

I suspect that you are falling into items 3 and 4, and the name of the window isn't really "CPAN - Google Search". (In my browser, the window is titled "CPAN - Google Search - Mozilla Firefox".)

Update -- Cleaned up the syntax in the first sentence.

----
I Go Back to Sleep, Now.

OGB

Replies are listed 'Best First'.
Re^2: Searching for a window using www::selenium
by venkatesan_G02 (Sexton) on Feb 03, 2010 at 16:16 UTC
    Hi,

    Is there a way to find the ID of the open window. Please note that the window is not opened by window.open command.
      venkatesan_G02,
      Have you read Using WWW::Selenium To Test Or Automate An Ajax Website? In there, I showed an example of how to find a window not opened with window.open. It might not be immediately useful but if you combine it with some of the other Selenium methods (get_all_window_ids or get_all_window_titles), you should be able to figure it out.

      Cheers - L~R