By the way, I have noticed similar behaviour. This seems to only
happen in win7, since in XP i have all those tests passing. I'm not
sure if it is a test fault or something with the actual code itself. I
haven't had any problems attaching to windows in real situation by
using 1.6.5 on win7.

And attach code hasn't changed between 1.6.5 and now so i'd bet more
on a strange test. If you manage to make it pass under win7 then don't
be afraid to make a pull request :)

Jarmo

On Wed, Sep 22, 2010 at 8:56 PM, Robert Pyron <[email protected]> wrote:
> Here is output from a unit test (much stuff elided):
> ----------------------------------------------------
>
>> Loaded suite
>> C:/work/watir/commonwatir/unittests/attach_to_existing_window_test
>> ...
>>
>>   1) Error:
>> test_existing_window(TC_ExistingWindow):
>> Watir::Exception::NoMatchingWindowFoundException: Unable to locate a
>> window with title of (?i-mx:buttons)
>>     C:/work/watir/watir/lib/watir/ie-class.rb:306:in
>> `attach_browser_window'
>>     ...
>>
>> C:/work/watir/commonwatir/unittests/attach_to_existing_window_test.rb:46:in
>> `test_existing_window'
>>
>>   2) Error:
>> test_working_back_and_forth(TC_ExistingWindow):
>> Watir::Exception::NoMatchingWindowFoundException: Unable to locate a
>> window with url of (?-mix:buttons1.html)
>>     C:/work/watir/watir/lib/watir/ie-class.rb:306:in
>> `attach_browser_window'
>>     ...
>>
>> C:/work/watir/commonwatir/unittests/attach_to_existing_window_test.rb:70:in
>> `test_working_back_and_forth'
>>
>> 4 tests, 8 assertions, 0 failures, 2 errors
>
> ----------------------------------------------------
>
> The setup method for the unit test class (TC_ExistingWindow) calls
>         uses_page "pass.html"
>
> 'uses_page' looks like this
>         def uses_page page # only works with IE
>             new_url = self.class.html_root + page
>             browser.goto new_url unless browser.url == new_url
>         end
>
> Getting back to the unit test, every test that tries to attach calls
> 'open_several_windows', which looks like this:
>         def open_several_windows
>             ["buttons1.html", "whitespace.html"].each do |file|
>                 @browsers << Browser.start(self.class.html_root + file)
>             end
>         end
>
> In other words, there are different ways to open the test windows.
>
> Now look at 'attach_browser_window how, what'. This method calls
> 'IE._find how, what', which has the following code:
>         IE.each do |ie|
>             window = ie.ie
>
> In my testing, 'IE.each' only gives one window, for URL "pass.html".
> The other windows are not in this list. Thus, every test that actually
> tries to attach to a browser window fails.
>
> Windows 7 32-bit, running as administrator
> Watir 1.6.5, development version from github.com
> Ruby 1.8.7
>
>
> _______________________________________________
> Wtr-development mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-development
>
_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development

Reply via email to