Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# watir/element.rb
def click_no_wait
assert_enabled
highlight(:set)
object = "#{self.class}.new(self, :unique_number, #{self.unique_number})"
@page_container.eval_in_spawned_process(object + ".click!")
highlight(:clear)
end
# watir/page-container.rb
def eval_in_spawned_process(command)
command.strip!
load_path_code = _code_that_copies_readonly_array($LOAD_PATH, '$LOAD_PATH')
ruby_code = "require 'watir/ie'; "
ruby_code << "pc = #{attach_command}; " # pc = page container
ruby_code << "pc.instance_eval(#{command.inspect})"
exec_string = "start rubyw -e #{(load_path_code + '; ' + ruby_code).inspect}"
system(exec_string)
end
# watir/ie.rb
def _code_that_copies_readonly_array(array, name)
"temp = Array.new(#{array.inspect}); #{name}.clear; temp.each {|element| #{name} << element}"
end
def click_no_wait
# ...
system(spawned_click_no_wait_command(ruby_code))
end
def spawned_click_no_wait_command(command)
command = "-e #{command.inspect}"
unless $DEBUG
"start rubyw #{command}"
else
puts "#click_no_wait command:"
command = "ruby #{command}"
puts command
command
end
end
$DEBUG = true
browser.button(:id => "something").click_no_wait
def click_no_wait
assert_exists
assert_enabled
highlight(:set)
element = "#{self.class}.new(#{@page_container.attach_command}, :unique_number, #{self.unique_number})"
ruby_code = "require 'rubygems';" <<
"require '#{File.expand_path(File.dirname(__FILE__))}/core';" <<
"#{element}.click!"
system(spawned_click_no_wait_command(ruby_code))
highlight(:clear)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment