How do I switch window , below is my code which works when I execute step 
by step in debugger


require 'win32ole'
sleep 1
wsh = WIN32OLE.new('Wscript.Shell')


@browser.div(:class => "k-button k-upload-button").click


@browser.windows.last.use
sleep 2
##@browser.windows.first.use
if window.exists? == true
  sleep 2
  wsh.AppActivate("File Upload")
  sleep 2
  wsh.SendKeys "{TAB}"
  sleep 1
  wsh.SendKeys("File_Path")
  sleep 1
  wsh.SendKeys "~"
end


---->
Code breaks after, it never execute the statements after that.

@browser.div(:class => "k-button k-upload-button").click

### App opens windows upload file dialog box

## And the code throws error :

##   Net::ReadTimeout (Net::ReadTimeout)

---->


Thanks,
Sudarshan


On Friday, October 7, 2011 at 12:54:53 PM UTC-4, Chuck van der Linden wrote:
>
> On Oct 6, 8:36 am, Rick <[email protected]> wrote: 
> > Trying to switch back to the main window from a popup with the 
> > following 
> > 
> > browser.window(:title => 'mytitle').use do 
> >      . 
> >      . 
> >      . 
> >      browser.frame(:id => 'bottomFrame').button(:id => 
> > 'btnClose').click 
> > end 
> > 
> > # I need to do something with the main window here 
> > 
> > At this point, i tried several things including 
> > 
> >  browser.window(:title => 'mainWindow').use 
> > 
> > But nothing seems to work to get me back to the main window.  Getting 
> > these 
> > 
> > Selenium::WebDriver::Error::ObsoleteElementError: Element not found in 
> > the cache 
> >     [remote server] 
> > file:///tmp/webdriver-profile20111005-29818-1mc4n0x/extensions/
> [email protected]/resource/modules/utils.js:8908:in 
> > `WebDriverError' 
> > 
> > Any ideas? 
>
> Are you sure you have the title for the main window correct? 
>
> You might try browser.windows to get a list of the windows at that 
> point 
>
> No time to test it right now, but maybe you could use this to debug 
> things a little at that point in your script. (or get the browser to 
> the right point and use IRB) 
>
> browser.windows.each_with_index do |win, i | 
>   puts i 
>   puts win.title 
>   puts win.url 
> end 
>
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to