Sha256: 75fd3f0fc2e87c8900bb1cdfd71cd2bdc0d9b359c019255bb9690eba61e84651

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module ImageWrap
  def self.included(klass)
    klass.instance_methods(false).each do |existing_method|
      if existing_method == :click
        wrap(klass, existing_method)
      end
    end
  end
    
  def self.wrap(klass, method) 
    klass.class_eval do
      name = method.to_s
      original_method = instance_method(name)

      define_method(name) do |*args, &block|
        TestExtention.screen_shot($current_test_method, 'pre')
        result = original_method.bind(self).call(*args, &block)
        TestExtention.screen_shot($current_test_method, 'post')
        result
      end
    end
  end
end

module Watir
  module Screen
    def self.shot
      if RUBY_PLATFORM =~ /win/i
        width, height, bitmap = Win32::Screenshot.desktop
        img_lst = Magick::ImageList.new
        img_lst.from_blob(bitmap)
      else 
        Magick::Image.capture(silent=true, frame=false, descent=false, 
                              screen=true, borders=false) { self.filename = 'root' }
      end
    end
  end
  class Element
    include ImageWrap
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qa_robusta-0.1.4 qa_observer/lib/watir.rb
qa_robusta-0.1.3 qa_observer/lib/watir.rb