poltergeist 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,6 +54,16 @@ module Capybara
54
54
  end
55
55
  end
56
56
 
57
+ class FrameNotFound < ClientError
58
+ def name
59
+ response['args'].first
60
+ end
61
+
62
+ def message
63
+ "The frame '#{name}' was not found."
64
+ end
65
+ end
66
+
57
67
  class NodeError < ClientError
58
68
  attr_reader :node
59
69
 
@@ -73,19 +83,24 @@ module Capybara
73
83
  end
74
84
  end
75
85
 
76
- class ClickFailed < NodeError
77
- def selector
86
+ class MouseEventFailed < NodeError
87
+ def name
78
88
  response['args'][0]
79
89
  end
80
90
 
91
+ def selector
92
+ response['args'][1]
93
+ end
94
+
81
95
  def position
82
- [response['args'][1]['x'], response['args'][1]['y']]
96
+ [response['args'][2]['x'], response['args'][2]['y']]
83
97
  end
84
98
 
85
99
  def message
86
- "Click at co-ordinates [#{position.join(', ')}] failed. Poltergeist detected " \
100
+ "Firing a #{name} at co-ordinates [#{position.join(', ')}] failed. Poltergeist detected " \
87
101
  "another element with CSS selector '#{selector}' at this position. " \
88
- "It may be overlapping the element you are trying to click."
102
+ "It may be overlapping the element you are trying to interact with. " \
103
+ "If you don't care about overlapping elements, try using node.trigger('#{name}')."
89
104
  end
90
105
  end
91
106
 
@@ -22,19 +22,31 @@ module Capybara::Poltergeist
22
22
  case error.name
23
23
  when 'Poltergeist.ObsoleteNode'
24
24
  raise ObsoleteNode.new(self, error.response)
25
- when 'Poltergeist.ClickFailed'
26
- raise ClickFailed.new(self, error.response)
25
+ when 'Poltergeist.MouseEventFailed'
26
+ raise MouseEventFailed.new(self, error.response)
27
27
  else
28
28
  raise
29
29
  end
30
30
  end
31
31
 
32
- def find(selector)
33
- command(:find_within, selector).map { |id| self.class.new(driver, page_id, id) }
32
+ def find(method, selector)
33
+ command(:find_within, method, selector).map { |id| self.class.new(driver, page_id, id) }
34
34
  end
35
35
 
36
- def text
37
- command(:text).gsub(NBSP, ' ').gsub(/\s+/u, ' ').strip
36
+ def find_xpath(selector)
37
+ find :xpath, selector
38
+ end
39
+
40
+ def find_css(selector)
41
+ find :css, selector
42
+ end
43
+
44
+ def all_text
45
+ filter_text command(:all_text)
46
+ end
47
+
48
+ def visible_text
49
+ filter_text command(:visible_text)
38
50
  end
39
51
 
40
52
  def [](name)
@@ -88,6 +100,10 @@ module Capybara::Poltergeist
88
100
  self[:selected]
89
101
  end
90
102
 
103
+ def disabled?
104
+ command :disabled?
105
+ end
106
+
91
107
  def click
92
108
  command :click
93
109
  end
@@ -96,6 +112,10 @@ module Capybara::Poltergeist
96
112
  command :double_click
97
113
  end
98
114
 
115
+ def hover
116
+ command :hover
117
+ end
118
+
99
119
  def drag_to(other)
100
120
  command :drag, other.id
101
121
  end
@@ -107,5 +127,11 @@ module Capybara::Poltergeist
107
127
  def ==(other)
108
128
  command :equals, other.id
109
129
  end
130
+
131
+ private
132
+
133
+ def filter_text(text)
134
+ text.gsub(NBSP, ' ').gsub(/\s+/u, ' ').strip
135
+ end
110
136
  end
111
137
  end
@@ -0,0 +1,9 @@
1
+ module Capybara
2
+ module Poltergeist
3
+ class << self
4
+ def windows?
5
+ RbConfig::CONFIG["host_os"] =~ /mingw|mswin|cygwin/
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Poltergeist
3
- VERSION = "1.1.2"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poltergeist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-11 00:00:00.000000000 Z
12
+ date: 2013-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.0.1
21
+ version: 2.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 2.0.1
29
+ version: 2.1.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: http_parser.rb
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -49,6 +49,9 @@ dependencies:
49
49
  none: false
50
50
  requirements:
51
51
  - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.4'
54
+ - - ! '>='
52
55
  - !ruby/object:Gem::Version
53
56
  version: 0.4.4
54
57
  type: :runtime
@@ -57,6 +60,9 @@ dependencies:
57
60
  none: false
58
61
  requirements:
59
62
  - - ~>
63
+ - !ruby/object:Gem::Version
64
+ version: '0.4'
65
+ - - ! '>='
60
66
  - !ruby/object:Gem::Version
61
67
  version: 0.4.4
62
68
  - !ruby/object:Gem::Dependency
@@ -98,7 +104,7 @@ dependencies:
98
104
  requirements:
99
105
  - - ~>
100
106
  - !ruby/object:Gem::Version
101
- version: 0.9.2
107
+ version: '10.0'
102
108
  type: :development
103
109
  prerelease: false
104
110
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +112,7 @@ dependencies:
106
112
  requirements:
107
113
  - - ~>
108
114
  - !ruby/object:Gem::Version
109
- version: 0.9.2
115
+ version: '10.0'
110
116
  - !ruby/object:Gem::Dependency
111
117
  name: image_size
112
118
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +195,7 @@ files:
189
195
  - lib/capybara/poltergeist/network_traffic/response.rb
190
196
  - lib/capybara/poltergeist/version.rb
191
197
  - lib/capybara/poltergeist/driver.rb
198
+ - lib/capybara/poltergeist/utility.rb
192
199
  - lib/capybara/poltergeist/client/connection.coffee
193
200
  - lib/capybara/poltergeist/client/node.coffee
194
201
  - lib/capybara/poltergeist/client/compiled/agent.js
@@ -226,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
233
  version: '0'
227
234
  segments:
228
235
  - 0
229
- hash: 2858802430034504505
236
+ hash: 1657182441903472235
230
237
  requirements: []
231
238
  rubyforge_project:
232
239
  rubygems_version: 1.8.24