Created
October 19, 2010 18:47
-
-
Save jarmo/634798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$DEBUG = true | |
browser.button(:id => "something").click_no_wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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