[Wtr-general] Can Watir be paused & resumed manually
Jason He
Jason.He at resilience.com
Thu Mar 1 01:34:13 EST 2007
As you mentioned, the "gets" will block the whole threads, maybe it need to be replaced by other key press input method. Is there an equivalent method in Ruby like trap method in Perl?
Regards,
Jason
-----Original Message-----
From: wtr-general-bounces at rubyforge.org [mailto:wtr-general-bounces at rubyforge.org] On Behalf Of John Lolis
Sent: 2007年2月28日 21:27
To: wtr-general at rubyforge.org
Subject: Re: [Wtr-general] Can Watir be paused & resumed manually
You are looking for some kind of interactive script. I can't imagine its too hard to do, but I don't have much time to mess around with it. Heres a fun little script i put together to test out an idea. Maybe it will spark some ideas.
(note: do not use this for anything, its just for fun. Also, 'gets' blocks all threads, so it doesn't even work right. Enjoy :) )
class Console_Test
def run
done = false
while !done
input_string = gets.chomp!
if input_string == 'wait'
puts '*sleeping*'
sleep 5
puts '*awake*'
end
if input_string == 'done'
done = true
puts '*done*'
end
end
end
end
class Testing
def run
done = false
i = 1
while !done
puts 'Current: ' + i.to_s
sleep 1
i += 1
if i > 10
done = true
end
end
end
end
test = Testing.new()
console = Console_Test.new()
threads = []
threads << Thread.new{ console.run() }
threads << Thread.new{ test.run() }
threads.each {|t| t.join }
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6704&messageID=19346#19346
_______________________________________________
Wtr-general mailing list
Wtr-general at rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general
More information about the Wtr-general
mailing list