Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

converted send keys to module, and sending the inclusion to node

  • Loading branch information...
commit 505ca47b49ae1fa496311dfb3cfc19a24f395092 1 parent b035ba6
@markgandolfo authored
Showing with 62 additions and 63 deletions.
  1. +62 −63 lib/send-keys/support/send_keys.rb
View
125 lib/send-keys/support/send_keys.rb
@@ -1,70 +1,69 @@
-class Capybara::Driver::Selenium < Capybara::Driver::Base
- class Node < Capybara::Node
-
- def allowed_keys
- @allowed_keys ||= %w(
- option
- null
- cancel
- help
- backspace
- tab
- clear
- return
- enter
- shift
- left_shift
- control
- left_control
- alt
- left_alt
- pause
- escape
- space
- page_up
- page_down
- end
- home
- left
- arrow_left
- uparrow_up
- right
- arrow_rightdown
- arrow_down
- insert
- delete
- semicolon
- equals
- numpad0 numpad1 numpad2 numpad3 numpad4 numpad5 numpad6 numpad7 numpad8 numpad9
- multiplyadd
- separator
- subtract
- decimal
- divide
- f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
- ).index_by {|k|k}
+module SendKeys
+ def allowed_keys
+ @allowed_keys ||= %w(
+ option
+ null
+ cancel
+ help
+ backspace
+ tab
+ clear
+ return
+ enter
+ shift
+ left_shift
+ control
+ left_control
+ alt
+ left_alt
+ pause
+ escape
+ space
+ page_up
+ page_down
+ end
+ home
+ left
+ arrow_left
+ uparrow_up
+ right
+ arrow_rightdown
+ arrow_down
+ insert
+ delete
+ semicolon
+ equals
+ numpad0 numpad1 numpad2 numpad3 numpad4 numpad5 numpad6 numpad7 numpad8 numpad9
+ multiplyadd
+ separator
+ subtract
+ decimal
+ divide
+ f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
+ ).index_by {|k|k}
+ end
+
+ def send_string_of_keys(key)
+ send_key = []
+
+ if matches = key.match(%r{^\[(.*)\]$})
+ key = matches[1].split(',').map(&:strip)
+ else
+ key = [key]
end
-
- def send_string_of_keys(key)
- send_key = []
- if matches = key.match(%r{^\[(.*)\]$})
- key = matches[1].split(',').map(&:strip)
+ key.each do |k|
+ if matches = k.match(%r{^['"](.*)['"]$})
+ send_key << matches[1]
+ elsif allowed_keys.has_key?(k)
+ send_key << k.to_sym
else
- key = [key]
+ send_key << k.to_s
end
-
- key.each do |k|
- if matches = k.match(%r{^['"](.*)['"]$})
- send_key << matches[1]
- elsif allowed_keys.has_key?(k)
- send_key << k.to_sym
- else
- send_key << k.to_s
- end
- end
-
- node.send_keys(send_key)
end
+
+ node.send_keys(send_key)
end
end
+
+Capybara::Node.send :include, SendKeys
Please sign in to comment.
Something went wrong with that request. Please try again.