selenium-webdriver 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ require "selenium/webdriver/target_locator"
9
9
  require "selenium/webdriver/navigation"
10
10
  require "selenium/webdriver/options"
11
11
  require "selenium/webdriver/find"
12
+ require "selenium/webdriver/keys"
12
13
  require "selenium/webdriver/bridge_helper"
13
14
  require "selenium/webdriver/driver"
14
15
  require "selenium/webdriver/element"
@@ -29,10 +29,16 @@ module Selenium
29
29
  bridge.getElementText @id
30
30
  end
31
31
 
32
- # FIXME: send_keys args
33
32
  def send_keys(*args)
34
- args.each { |str| bridge.sendKeysToElement(@id, str) }
33
+ args.each do |arg|
34
+ if arg.kind_of?(Symbol)
35
+ arg = Keys[arg]
36
+ end
37
+
38
+ bridge.sendKeysToElement(@id, arg.to_s)
39
+ end
35
40
  end
41
+ alias_method :send_key, :send_keys
36
42
 
37
43
  def clear
38
44
  bridge.clearElement @id
@@ -0,0 +1,76 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module Keys
4
+
5
+ # \x works on both 1.8.6/1.9
6
+ KEYS = {
7
+ :null => "\xEE\x80\x80",
8
+ :cancel => "\xEE\x80\x81",
9
+ :help => "\xEE\x80\x82",
10
+ :back_space => "\xEE\x80\x83",
11
+ :tab => "\xEE\x80\x84",
12
+ :clear => "\xEE\x80\x85",
13
+ :return => "\xEE\x80\x86",
14
+ :enter => "\xEE\x80\x87",
15
+ :shift => "\xEE\x80\x88",
16
+ :left_shift => "\xEE\x80\x88",
17
+ :control => "\xEE\x80\x89",
18
+ :left_control => "\xEE\x80\x89",
19
+ :alt => "\xEE\x80\x8A",
20
+ :left_alt => "\xEE\x80\x8A",
21
+ :pause => "\xEE\x80\x8B",
22
+ :escape => "\xEE\x80\x8C",
23
+ :space => "\xEE\x80\x8D",
24
+ :page_up => "\xEE\x80\x8E",
25
+ :page_down => "\xEE\x80\x8F",
26
+ :end => "\xEE\x80\x90",
27
+ :home => "\xEE\x80\x91",
28
+ :left => "\xEE\x80\x92",
29
+ :arrow_left => "\xEE\x80\x92",
30
+ :up => "\xEE\x80\x93",
31
+ :arrow_up => "\xEE\x80\x93",
32
+ :right => "\xEE\x80\x94",
33
+ :arrow_right => "\xEE\x80\x94",
34
+ :down => "\xEE\x80\x95",
35
+ :arrow_down => "\xEE\x80\x95",
36
+ :insert => "\xEE\x80\x96",
37
+ :delete => "\xEE\x80\x97",
38
+ :semicolon => "\xEE\x80\x98",
39
+ :equals => "\xEE\x80\x99",
40
+ :numpad0 => "\xEE\x80\x9A",
41
+ :numpad1 => "\xEE\x80\x9B",
42
+ :numpad2 => "\xEE\x80\x9C",
43
+ :numpad3 => "\xEE\x80\x9D",
44
+ :numpad4 => "\xEE\x80\x9E",
45
+ :numpad5 => "\xEE\x80\x9F",
46
+ :numpad6 => "\xEE\x80\xA0",
47
+ :numpad7 => "\xEE\x80\xA1",
48
+ :numpad8 => "\xEE\x80\xA2",
49
+ :numpad9 => "\xEE\x80\xA3",
50
+ :multiply => "\xEE\x80\xA4",
51
+ :add => "\xEE\x80\xA5",
52
+ :separator => "\xEE\x80\xA6",
53
+ :subtract => "\xEE\x80\xA7",
54
+ :decimal => "\xEE\x80\xA8",
55
+ :divide => "\xEE\x80\xA9",
56
+ :f1 => "\xEE\x80\xB1",
57
+ :f2 => "\xEE\x80\xB2",
58
+ :f3 => "\xEE\x80\xB3",
59
+ :f4 => "\xEE\x80\xB4",
60
+ :f5 => "\xEE\x80\xB5",
61
+ :f6 => "\xEE\x80\xB6",
62
+ :f7 => "\xEE\x80\xB7",
63
+ :f8 => "\xEE\x80\xB8",
64
+ :f9 => "\xEE\x80\xB9",
65
+ :f10 => "\xEE\x80\xBA",
66
+ :f11 => "\xEE\x80\xBB",
67
+ :f12 => "\xEE\x80\xBC"
68
+ }
69
+
70
+ def self.[](key)
71
+ KEYS[key] || raise(Error::UnsupportedOperationError, "no such key #{e.inspect}")
72
+ end
73
+
74
+ end # Keys
75
+ end # WebDriver
76
+ end # Selenium
@@ -13,7 +13,7 @@ module Selenium
13
13
  loop do
14
14
  begin
15
15
  return new_socket
16
- rescue Errno::ECONNREFUSED => e
16
+ rescue Errno::ECONNREFUSED, Errno::ENOTCONN => e
17
17
  $stderr.puts "#{self} caught #{e.message}" if $DEBUG
18
18
  sleep 0.250
19
19
  end
@@ -73,7 +73,7 @@ module Selenium
73
73
  connection = ExtensionConnection.new(@host, @port)
74
74
  connection.connect(1)
75
75
  connection.quit
76
- rescue Errno::ECONNREFUSED, Timeout::Error => e
76
+ rescue Errno::ECONNREFUSED, Errno::ENOTCONN, Timeout::Error => e
77
77
  # ok
78
78
  end
79
79
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -68,6 +68,7 @@ files:
68
68
  - common/src/rb/lib/selenium/webdriver/element.rb
69
69
  - common/src/rb/lib/selenium/webdriver/error.rb
70
70
  - common/src/rb/lib/selenium/webdriver/find.rb
71
+ - common/src/rb/lib/selenium/webdriver/keys.rb
71
72
  - common/src/rb/lib/selenium/webdriver/navigation.rb
72
73
  - common/src/rb/lib/selenium/webdriver/options.rb
73
74
  - common/src/rb/lib/selenium/webdriver/platform.rb