[wtr-general] Problem with firewatir hanging on close
Hi, I've been seeing a very sporadic issue with closing a firefox instance with firewatir 1.6.7. I'm running the following code to attach to an existing window and close it: require "rubygems" require "watir" Watir::Browser.default = 'firefox' puts('ruby: attaching to browser') b = Watir::Browser.attach(:title, /.*/); puts('ruby: closing browser') b.close puts('ruby: browser closed') Rarely, maybe 1 in 15 times this hangs and I don't get the "ruby: browser closed" line printed to standard out. When I hit CTRL-C I get the following trace. C:/Ruby186/lib/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/ jssh_socket.rb:63:in 'recv': Interrupt from C:/Ruby186/lib/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/ jssh_socket.rb:63:in 'read_socket' from C:/Ruby186/lib/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/ jssh_socket.rb:54:in 'each' from C:/Ruby186/lib/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/ jssh_socket.rb:63:in 'read_socket' from C:/Ruby186/lib/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/ jssh_socket.rb:63:in 'js_eval' from C:/Ruby186/lib/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/ firefox.rb:220:in 'close' from ./Ruby/close.rb:8 I've seen this across a number of Windows 7 systems, all 3.6.* versions of Firefox, all systems only had one instance fo Firefox open with one tab open two. Although I say I've seen this happen 1 in 15 times, I've also managed to run 100 tests in a row that do the same thing and have no problem. This is really starting to annoy me now. Anyone have any suggestions? -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
[wtr-general] Intermittent Watir issue with Firefox
Hi, I'm seeing an intermittent watir issue with firefox. I really don't know whats causing it, I can't seem to cause it to happen reliably. I've seen a thread from last may discussing something similar and a really hacky work around:http://osdir.com/ml/watir-general/2010-05/msg00134.html I guess I'm hoping some better solution might have popped up in the meantime. It's giving me the following error. C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/jssh_socket.rb:19:in `js_eval': this.docShell is null (JsshSocket::JSTypeError) C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/firefox.rb:194:in `set_browser_document' C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/firefox.rb:52:in `initialize' C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/watir/browser.rb:65:in `new' C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/watir/browser.rb:65:in `new' from ./Ruby/goto.rb:7 and goto.rb is here: require "rubygems" require "watir" puts('ruby: Using firefox') Watir::Browser.default = 'firefox' puts('ruby: Starting browser') b = Watir::Browser.new puts('ruby: Browser started') b.maximize b.goto(ARGV[0]) Any ideas? Cheers, -- Stephen Mc Gowan. -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Intermittent Watir issue with Firefox
I'm using it as the Watir in 5 minutes tutorial, from Watir's homepage, says to: http://wiki.openqa.org/display/WTR/Watir+in+5+Minutes Watir::Browser.default = 'firefox' b = Watir::Browser.new Firewatir and watir have merged so you only need to do this now and you don't have to specifically reference firewatir...at least thats what I'm lead to believe. On Thu, Feb 3, 2011 at 2:22 PM, Prajakta Jadhav wrote: > How are you using 'watir' for firefox? You should be using 'firewatir', > right? > > -Prajakta > > On Thu, Feb 3, 2011 at 7:43 PM, Stephen Mc Gowan wrote: > >> Hi, >> >> I'm seeing an intermittent watir issue with firefox. I really don't know >> whats causing it, I can't seem to cause it to happen reliably. I've seen a >> thread from last may discussing something similar and a really hacky work >> around:http://osdir.com/ml/watir-general/2010-05/msg00134.html >> >> I guess I'm hoping some better solution might have popped up in the >> meantime. >> >> It's giving me the following error. >> >> >> C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/jssh_socket.rb:19:in >> `js_eval': this.docShell is null (JsshSocket::JSTypeError) >> >> C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/firefox.rb:194:in >> `set_browser_document' >> >> C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/firefox.rb:52:in >> `initialize' >> >> C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/watir/browser.rb:65:in >> `new' >> >> C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/watir/browser.rb:65:in >> `new' >> from ./Ruby/goto.rb:7 >> >> and goto.rb is here: >> >> require "rubygems" >> require "watir" >> >> puts('ruby: Using firefox') >> Watir::Browser.default = 'firefox' >> puts('ruby: Starting browser') >> >> >> >> >> b = Watir::Browser.new >> puts('ruby: Browser started') >> b.maximize >> b.goto(ARGV[0]) >> >> >> Any ideas? >> >> Cheers, >> -- >> Stephen Mc Gowan. >> >> -- >> Before posting, please read http://watir.com/support. In short: search >> before you ask, be nice. >> >> watir-general@googlegroups.com >> http://groups.google.com/group/watir-general >> watir-general+unsubscr...@googlegroups.com >> > > -- > Before posting, please read http://watir.com/support. In short: search > before you ask, be nice. > > watir-general@googlegroups.com > http://groups.google.com/group/watir-general > watir-general+unsubscr...@googlegroups.com > -- Stephen Mc Gowan. -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Intermittent Watir issue with Firefox
Hey, Thanks for the reply, this looks like a much better solution. But you're right it would be good if we could pass firefox arguments in Browser.new(). Anyone have any ideas? Cheers, Stephen On Tue, Feb 8, 2011 at 12:30 AM, Bill Agee wrote: > Hi, > > Since posting that suggestion for that hack to rescue/retry a failed > Firefox launch, I tried another approach which worked a little better. :) > > To give the Firefox browser instance more time to initialize before > FireWatir tries to drive it, you can pass an optional wait time value (at > least if you're using Firefox.new directly). This makes FireWatir sleep > after launching the browser: > > ff = FireWatir::Firefox.new( { :waitTime => 10 } ) > > 10 seconds seems to be enough to get rid of any errors on my FireWatir > machines, no matter how slow and clunky they are...I haven't seen any FF > launch problems since increasing this wait value. > > My guess at where the problem lies: > > It looks like Firefox#launch_browser contains a default sleep time of 2 > seconds to allow FF to initialize before trying to drive it. > > But in my experience, on slow Vista/Win7 machines (and even some XP > machines), 2 seconds isn't enough, and so exceptions often occur at launch, > apparently due to FF not being ready when FireWatir plows ahead and tries to > drive the browser. > > This may be the cause of the infamous "JsshSocket::JSTypeError: > this.docShell is null" exception when launching Firefox. > > Side note: It would be nice if the launch_browser method could poll Firefox > to determine when the browser is ready, rather than sleeping using the wait > time value. > > > Also, there's one complication to this technique - I haven't been able to > figure out how to make Browser.new accept any Firefox options. > > Does anybody know how to define Firefox options (like :waitTime) before > starting Firefox with Browser.new? I experimented with the source of > commonwatir a bit, but I wasn't successful in setting the :waitTime option > and having Firefox actually use it. > > In the meantime, to increase the default Firefox startup wait time while > also using Browser.new to launch FF, I'm using a hack of monkeypatching > Firefox#launch_browser to increase the default wait time: > > def launch_browser(options = {}) > > > > bin = path_to_bin() > @t = Thread.new { system("#{bin} -jssh #{profile_opt}") } > #FIXME: Original line: > #sleep options[:waitTime] || 2 > sleep options[:waitTime] || 10 > > > But monkeypatching this entire method is bad...I need to find a better way > that will not complicate Watir upgrades. > > Thanks > Bill > > On Thu, Feb 3, 2011 at 6:13 AM, Stephen Mc Gowan wrote: > >> Hi, >> >> I'm seeing an intermittent watir issue with firefox. I really don't know >> whats causing it, I can't seem to cause it to happen reliably. I've seen a >> thread from last may discussing something similar and a really hacky work >> around:http://osdir.com/ml/watir-general/2010-05/msg00134.html >> >> I guess I'm hoping some better solution might have popped up in the >> meantime. >> >> It's giving me the following error. >> >> >> C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/jssh_socket.rb:19:in >> `js_eval': this.docShell is null (JsshSocket::JSTypeError) >> >> C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/firefox.rb:194:in >> `set_browser_document' >> >> C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/firewatir/firefox.rb:52:in >> `initialize' >> >> C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/watir/browser.rb:65:in >> `new' >> >> C:/Ruby186/lib/ruby/gems/1.8/gems/firewatir-1.6.7/lib/watir/browser.rb:65:in >> `new' >> from ./Ruby/goto.rb:7 >> >> and goto.rb is here: >> >> require "rubygems" >> require "watir" >> >> puts('ruby: Using firefox') >> Watir::Browser.default = 'firefox' >> puts('ruby: Starting browser') >> >> >> >> >> b = Watir::Browser.new >> puts('ruby: Browser started') >> b.maximize >> b.goto(ARGV[0]) >> >> >> Any ideas? >> >> Cheers, >> -- >> Stephen Mc Gowan. >> >> -- >> Before posting, please read http://watir.com/support. In short: search >> before you ask, be nice. >> >> watir-general@googlegroups.com >> http://groups.google.com/group/watir-general >> watir-general+unsubscr...@googlegroups.com >> > > -- > Before posting, please read http://watir.com/support. In short: search > before you ask, be nice. > > watir-general@googlegroups.com > http://groups.google.com/group/watir-general > watir-general+unsubscr...@googlegroups.com > -- Stephen Mc Gowan. -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com