That's exactly as what Prajakta said, you can try the method provided below.
def new_window
        # get a handle if one exists
        aa = Win32API.new("user32", "GetForegroundWindow",[] , 'L')
        hwnd = aa.call
        if (hwnd)  # yes there is a popup
            return Watir::IE.attach(:hwnd, hwnd)
        else
            return nil
        end
    end

$ie = Watir::IE.start("your_url")
$ie.link("your_link").click
if ie2 = new_window
    ie2.close
end

Thanks.
Wesley Chen.
For life, the easier, the better.


On Wed, Dec 30, 2009 at 9:26 PM, Prajakta Jadhav
<[email protected]>wrote:

> If in case you are clicking on some link/image which in turn opens a new
> browser window then u ll need to get the handle of that new window first.
> Then u can execute browser.close on it.
> U ll need to attach the new window to a new watir browser instance.
> eg ->
> ie2 = watir::IE.new
> ie2.attach(:url, <url of new browser window>)
> ie2.close
>
>
>
> On Wed, Dec 30, 2009 at 2:43 PM, Tester <[email protected]> wrote:
>
>> i am running a watir script on a url. The script opens pdf documents
>> in new windows. There are more that 100 pdf files on opening each in
>> new window the window hangs and I am not able to run the entire
>> script. Can some one help me out in this.
>> Is there a method such as ie.close to close the new browser window
>> getting opened from the main window in watir?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Watir General" group.
>> To post to this group, send email to [email protected]
>> Before posting, please read the following guidelines:
>> http://wiki.openqa.org/display/WTR/Support
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/watir-general
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Watir General" group.
> To post to this group, send email to [email protected]
> Before posting, please read the following guidelines:
> http://wiki.openqa.org/display/WTR/Support
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/watir-general
>

-- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/watir-general

Reply via email to