hey, all. I have one problem is stop current thread in ie.
The logic is: when i click button 'login google', it will open the
browser and input usename and password. When i am click pause/resume
button it will pause the input or resume the input.
I have tried many ways, but none of the can work. The follwing is my
code:
#google.rb
require 'rubygems'
require 'watir'
require 'watir/ie'



class LoginGoogle
  @ie = nil

  def login
    @ie = Watir::IE.new
    @ie.maximize
    @ie.goto('http://mail.google.com')
    @ie.typingspeed = 0.5 # slow down the typing speed
    @ie.text_field(:id, 'Email').set('AlexDev') if @ie.text_field(:id,
'Email').exists?
    @ie.text_field(:id, 'Passwd').set('xxxxxx') if @ie.text_field(:id,
'Passwd').exists?
    #[email protected](:name, 'signIn').click
  end
end

#gui.rb
require 'rubygems'
require 'thread'
require 'wx'
include Wx
require 'google.rb'


class MyFrame < Frame
  def initialize(title)
        super(nil, -1, 'form title', Point.new(-1,-1), Size.new(560,
472))
        @panel = Panel.new(self, -1)

        @button1 = Button.new(@panel, 1001, 'pause', Point.new
(96,128), Size.new(89, 29))

        @button2 = Button.new(@panel, 1002, 'login google', Point.new
(196,128), Size.new(89, 29))

        evt_button(1001){|event| btn_evt(event)  }
        evt_button(1002){|event| btn2_evt(event)  }
      end

  def btn_evt(event)
    if @button1.get_label =~ /pause/
      @button1.set_label('resume')
      # pause input, how to code it?

      #[email protected] #but no this method, how to stop @thread and
wakeup it?

    else
      @button1.set_label('pause')
      Thread.main.wakeup #resume input
    end
  end

  def btn2_evt(event)
    @thread = Thread.new do
       @g =LoginGoogle.new
       @g.login
    end

  end
end

class MinimalApp < Wx::App
  attr_accessor :thread
  def on_init

    frame = MyFrame.new('')
    frame.show(TRUE)
    Wx::Timer.every(55) do
      Thread.pass
    end

  end

end

$app = MinimalApp.new
$app.main_loop

Regards,
Alex.Dev
--~--~---------~--~----~------------~-------~--~----~
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