[
http://jira.openqa.org/browse/WTR-472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20087#action_20087
]
Jarmo Pertman commented on WTR-472:
-----------------------------------
Spent some more time investigating this issue.
I found out the reason why .start_process seemed to work before and not
anymore. Before IE.each returned always nil and now it returns the array
itself, because IE.each gathers all windows by using shell.Windows.each into a
Ruby Array before yielding them
(https://github.com/bret/watir/commit/ca7d0ec78ad80d44b57c11fa4ad72d2bc09d2e37).
Check this out:
irb(main):013:0> shell.Windows.each {}
=> nil
irb(main):014:0> [].each {}
=> []
This means that Wait.until used in Process#window (ie-process.rb) didn't wait
anymore for the process to start because an empty Array is as good as true in
Ruby thus Wait.until just returned and thought that everyone is happy. I've
fixed it in
(https://github.com/bret/watir/commit/1dfdfc1428ea97e1d0a565731af98453a23b79d9)
and .start_process is working again.
But why i mentioned that it "seemed to work" before? That's because it is only
working if you don't have any IE windows opened with .start_process before. So
if you do something like this:
{noformat}
Watir::IE.new # works
Watir::IE.start_process # works
Watir::IE.start_process # doesn't work, gets a timeout
{noformat}
On the other hand:
{noformat}
Watir::IE.new # works
browser = Watir::IE.start_process # works
browser.close # closes the browser opened by .start_process
Watir::IE.start_process # works
{noformat}
The reason is that Process.start in ie-process.rb uses win32/process .create
method to create new processes and if there's no existing IE processes created
by Process.create then everything works because the process_id returned by
Process.create is valid. If you use Process.create 2 times in a row then the
process_id is not valid anymore. That is happening because after Process.create
is used then 2 processes are created with name iexplore.exe.
I'm not sure why this is happening but it seems to be Windows itself doing
that. Anyway, the first process seems to be the "root" process and the second
one the actual visible process. When using Process.create for the second time
then also 2 processes will be created, but for some reason the first one will
be killed and the second one will have that previous "root" as it's parent. And
the process_id left for Watir is the one which got killed thus Watir won't find
the process it's looking for and will get a timeout. Always.
You can reproduce it easily like this:
{noformat}
require "win32/process"
proc = Process.create(:app_name => "C:\\Program Files (x86)\\Internet
Explorer\\iexplore.exe about:blank")
=> #<struct Struct::ProcessInfo process_handle=168, thread_handle=208,
process_id=3560, thread_id=7152>
Process.kill 9, proc.process_id
=> [3560]
proc = Process.create(:app_name => "C:\\Program Files (x86)\\Internet
Explorer\\iexplore.exe about:blank")
=> #<struct Struct::ProcessInfo process_handle=168, thread_handle=208,
process_id=5588, thread_id=6040>
proc = Process.create(:app_name => "C:\\Program Files (x86)\\Internet
Explorer\\iexplore.exe about:blank")
=> #<struct Struct::ProcessInfo process_handle=168, thread_handle=208,
process_id=6580, thread_id=1144>
Process.kill 9, proc.process_id
Process::Error: The handle is invalid.
from
c:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.6.5/lib/win32/process.rb:595:in
`kill'
from
c:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.6.5/lib/win32/process.rb:555:in
`each'
from
c:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.6.5/lib/win32/process.rb:555:in
`kill'
from (irb):17
from ♥:0
{noformat}
I also checked that the problems with IE.close_all (WTR-463) and using
IE.start_process multiple times both exist in Watir 1.6.5.
This could mean that IE.close_all is almost never used at all and
IE.start_process is not used multiple times in a row without closing previous
IE window(s).
I tested all on Windows 7 64bit, but it seems to be quite similar on XP 32bit
too.
I'm suggesting making a new release to "fix" IE.start_process ASAP to make it
work like it was before.
Is there also any reason why window_tests are not included into core_tests?
That's one of the reasons why the problem didn't come out before the release.
> Issues with Watir::IE::Process.start_process and new_process
> ------------------------------------------------------------
>
> Key: WTR-472
> URL: http://jira.openqa.org/browse/WTR-472
> Project: Watir
> Issue Type: Bug
> Components: Other
> Affects Versions: 1.6.7
> Environment: windows 7 IE 8
> Reporter: Alan Baird
> Priority: Major
>
> I noticed this on Ruby 1.8.7:
> {code}
> c:\>pik switch 1.8.7
> c:\>ruby -v
> ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
> c:\>gem list watir
> *** LOCAL GEMS ***
> watir (1.7.0, 1.7.0.rc1, 1.6.7)
> c:\>irb --noreadline
> irb(main):001:0> require 'watir'
> => true
> irb(main):002:0> br = Watir::IE.new_process
> NoMethodError: undefined method `visible' for [#<Watir::IE:0x57f6900
> url="about:blank" title="">]:Array
> from
> C:/ruby/Ruby-187-p302/lib/ruby/gems/1.8/gems/watir-1.7.0/lib/watir/ie-class.rb:230:in
> `visible='
> from
> C:/ruby/Ruby-187-p302/lib/ruby/gems/1.8/gems/watir-1.7.0/lib/watir/ie-class.rb:170:in
> `initialize_options'
> from
> C:/ruby/Ruby-187-p302/lib/ruby/gems/1.8/gems/watir-1.7.0/lib/watir/ie-class.rb:121:in
> `_new_process_init'
> from
> C:/ruby/Ruby-187-p302/lib/ruby/gems/1.8/gems/watir-1.7.0/lib/watir/ie-class.rb:113:in
> `new_process'
> from (irb):2
> irb(main):003:0> br = Watir::IE.start_process
> NoMethodError: undefined method `visible' for [#<Watir::IE:0x57f2850
> url="about:blank" title="">]:Array
> from
> C:/ruby/Ruby-187-p302/lib/ruby/gems/1.8/gems/watir-1.7.0/lib/watir/ie-class.rb:230:in
> `visible='
> from
> C:/ruby/Ruby-187-p302/lib/ruby/gems/1.8/gems/watir-1.7.0/lib/watir/ie-class.rb:170:in
> `initialize_options'
> from
> C:/ruby/Ruby-187-p302/lib/ruby/gems/1.8/gems/watir-1.7.0/lib/watir/ie-class.rb:121:in
> `_new_process_init'
> from
> C:/ruby/Ruby-187-p302/lib/ruby/gems/1.8/gems/watir-1.7.0/lib/watir/ie-class.rb:113:in
> `new_process'
> from
> C:/ruby/Ruby-187-p302/lib/ruby/gems/1.8/gems/watir-1.7.0/lib/watir/ie-class.rb:128:in
> `start_process'
> from (irb):3
> {code}
> I'm not sure what is causing this. I don't see this behavior with 1.8.6.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.openqa.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development