selenium-webdriver 2.18.0 → 2.19.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,31 +4,31 @@
4
4
  # object.
5
5
  module Selenium
6
6
  module Client
7
-
7
+
8
8
  module SeleniumHelper
9
-
9
+
10
10
  # Overrides default open method to actually delegates to @selenium
11
11
  def open(url)
12
12
  @selenium.open url
13
13
  end
14
-
14
+
15
15
  # Overrides default type method to actually delegates to @selenium
16
16
  def type(locator, value)
17
17
  @selenium.type locator, value
18
18
  end
19
-
19
+
20
20
  # Overrides default select method to actually delegates to @selenium
21
21
  def select(input_locator, option_locator)
22
22
  @selenium.select input_locator, option_locator
23
23
  end
24
24
 
25
- # Delegates to @selenium on method missing
25
+ # Delegates to @selenium on method missing
26
26
  def method_missing(method_name, *args)
27
27
  return super unless @selenium.respond_to?(method_name)
28
-
28
+
29
29
  @selenium.send(method_name, *args)
30
- end
30
+ end
31
31
  end
32
-
32
+
33
33
  end
34
34
  end
@@ -32,7 +32,8 @@ module Selenium
32
32
  DriverExtensions::HasInputDevices,
33
33
  DriverExtensions::HasWebStorage,
34
34
  DriverExtensions::HasLocation,
35
- DriverExtensions::HasBrowserConnection
35
+ DriverExtensions::HasBrowserConnection,
36
+ DriverExtensions::HasTouchScreen
36
37
  ]
37
38
  end
38
39
 
@@ -9,7 +9,7 @@ module Selenium
9
9
  class Service
10
10
  START_TIMEOUT = 20
11
11
  STOP_TIMEOUT = 5
12
- MISSING_TEXT = "Unable to find the chromedriver executable. Please download the server from http://code.google.com/p/chromium/downloads/list and place it somewhere on your PATH. More info at http://code.google.com/p/selenium/wiki/ChromeDriver."
12
+ MISSING_TEXT = "Unable to find the chromedriver executable. Please download the server from http://code.google.com/p/chromedriver/downloads/list and place it somewhere on your PATH. More info at http://code.google.com/p/selenium/wiki/ChromeDriver."
13
13
 
14
14
  attr_reader :uri
15
15
 
@@ -12,6 +12,7 @@ require 'selenium/webdriver/common/wait'
12
12
  require 'selenium/webdriver/common/alert'
13
13
  require 'selenium/webdriver/common/mouse'
14
14
  require 'selenium/webdriver/common/keyboard'
15
+ require 'selenium/webdriver/common/touch_screen'
15
16
  require 'selenium/webdriver/common/target_locator'
16
17
  require 'selenium/webdriver/common/navigation'
17
18
  require 'selenium/webdriver/common/timeouts'
@@ -19,6 +20,7 @@ require 'selenium/webdriver/common/window'
19
20
  require 'selenium/webdriver/common/options'
20
21
  require 'selenium/webdriver/common/search_context'
21
22
  require 'selenium/webdriver/common/action_builder'
23
+ require 'selenium/webdriver/common/touch_action_builder'
22
24
  require 'selenium/webdriver/common/html5/shared_web_storage'
23
25
  require 'selenium/webdriver/common/html5/local_storage'
24
26
  require 'selenium/webdriver/common/html5/session_storage'
@@ -28,6 +30,7 @@ require 'selenium/webdriver/common/driver_extensions/has_browser_connection'
28
30
  require 'selenium/webdriver/common/driver_extensions/has_input_devices'
29
31
  require 'selenium/webdriver/common/driver_extensions/has_web_storage'
30
32
  require 'selenium/webdriver/common/driver_extensions/has_location'
33
+ require 'selenium/webdriver/common/driver_extensions/has_touch_screen'
31
34
  require 'selenium/webdriver/common/driver_extensions/uploads_files'
32
35
  require 'selenium/webdriver/common/keys'
33
36
  require 'selenium/webdriver/common/bridge_helper'
@@ -0,0 +1,19 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module DriverExtensions
4
+
5
+ module HasTouchScreen
6
+ def touch
7
+ TouchActionBuilder.new mouse, keyboard, touch_screen
8
+ end
9
+
10
+ private
11
+
12
+ def touch_screen
13
+ TouchScreen.new @bridge
14
+ end
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -18,13 +18,14 @@ module Selenium
18
18
  # @api public
19
19
  #
20
20
 
21
- def rotate(orientation)
21
+ def rotation=(orientation)
22
22
  unless ORIENTATIONS.include?(orientation)
23
23
  raise ArgumentError, "expected #{ORIENTATIONS.inspect}, got #{orientation.inspect}"
24
24
  end
25
25
 
26
26
  bridge.setScreenOrientation(orientation.to_s.upcase)
27
27
  end
28
+ alias_method :rotate, :rotation=
28
29
 
29
30
  #
30
31
  # Get the current screen orientation
@@ -1,7 +1,10 @@
1
1
  module Selenium
2
2
  module WebDriver
3
3
 
4
+ #
4
5
  # @api private
6
+ # @see ActionBuilder
7
+
5
8
  class Keyboard
6
9
 
7
10
  def initialize(bridge)
@@ -1,7 +1,11 @@
1
1
  module Selenium
2
2
  module WebDriver
3
3
 
4
+ #
4
5
  # @api private
6
+ # @see ActionBuilder
7
+ #
8
+
5
9
  class Mouse
6
10
 
7
11
  def initialize(bridge)
@@ -0,0 +1,64 @@
1
+ module Selenium
2
+ module WebDriver
3
+ class TouchActionBuilder < ActionBuilder
4
+
5
+ #
6
+ # @api private
7
+ #
8
+
9
+ def initialize(mouse, keyboard, touch_screen)
10
+ super(mouse, keyboard)
11
+ @devices[:touch_screen] = touch_screen
12
+ end
13
+
14
+ def scroll(*args)
15
+ unless [2,3].include? args.size
16
+ raise ArgumentError, "wrong number of arguments, expected 2..3, got #{args.size}"
17
+ end
18
+
19
+ @actions << [:touch_screen, :scroll, args]
20
+ self
21
+ end
22
+
23
+ def flick(*args)
24
+ unless [2,4].include? args.size
25
+ raise ArgumentError, "wrong number of arguments, expected 2 or 4, got #{args.size}"
26
+ end
27
+
28
+ @actions << [:touch_screen, :flick, args]
29
+ self
30
+ end
31
+
32
+ def single_tap(element)
33
+ @actions << [:touch_screen, :single_tap, [element]]
34
+ self
35
+ end
36
+
37
+ def double_tap(element)
38
+ @actions << [:touch_screen, :double_tap, [element]]
39
+ self
40
+ end
41
+
42
+ def long_press(element)
43
+ @actions << [:touch_screen, :long_press, [element]]
44
+ self
45
+ end
46
+
47
+ def down(x, y = nil)
48
+ @actions << [:touch_screen, :down, [x, y]]
49
+ self
50
+ end
51
+
52
+ def up(x, y = nil)
53
+ @actions << [:touch_screen, :up, [x, y]]
54
+ self
55
+ end
56
+
57
+ def move(x, y = nil)
58
+ @actions << [:touch_screen, :move, [x, y]]
59
+ self
60
+ end
61
+
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,105 @@
1
+ module Selenium
2
+ module WebDriver
3
+ class TouchScreen
4
+ FLICK_SPEED = { :normal => 0, :fast => 1}
5
+
6
+
7
+ #
8
+ # @api private
9
+ #
10
+
11
+ def initialize(bridge)
12
+ @bridge = bridge
13
+ end
14
+
15
+ def single_tap(element)
16
+ assert_element element
17
+ @bridge.touchSingleTap element.ref
18
+ end
19
+
20
+ def double_tap(element)
21
+ assert_element element
22
+ @bridge.touchDoubleTap element.ref
23
+ end
24
+
25
+ def long_press(element)
26
+ assert_element element
27
+ @bridge.touchLongPress element.ref
28
+ end
29
+
30
+ def down(x, y = nil)
31
+ x, y = coords_from x, y
32
+ @bridge.touchDown x, y
33
+ end
34
+
35
+ def up(x, y = nil)
36
+ x, y = coords_from x, y
37
+ @bridge.touchUp x, y
38
+ end
39
+
40
+ def move(x, y = nil)
41
+ x, y = coords_from x, y
42
+ @bridge.touchMove x, y
43
+ end
44
+
45
+ def scroll(*args)
46
+ case args.size
47
+ when 2
48
+ x, y = args
49
+ @bridge.touchScroll nil, x, y
50
+ when 3
51
+ element, x_offset, y_offset = args
52
+ assert_element element
53
+ @bridge.touchScroll element.ref, Integer(x_offset), Integer(y_offset)
54
+ else
55
+ raise ArgumentError, "wrong number of arguments, expected 2..3, got #{args.size}"
56
+ end
57
+ end
58
+
59
+ def flick(*args)
60
+ case args.size
61
+ when 2
62
+ x_speed, y_speed = args
63
+ @bridge.touchFlick Integer(x_speed), Integer(y_speed)
64
+ when 4
65
+ element, xoffset, yoffset, speed = args
66
+
67
+ assert_element element
68
+ flick_speed = FLICK_SPEED[speed.to_sym]
69
+
70
+ unless flick_speed
71
+ raise ArgumentError, "expected one of #{FLICK_SPEED.keys.inspect}, got #{speed.inspect}"
72
+ end
73
+
74
+ @bridge.touchElementFlick element.ref, Integer(xoffset), Integer(yoffset), flick_speed
75
+ else
76
+ raise ArgumentError, "wrong number of arguments, expected 2 or 4, got #{args.size}"
77
+ end
78
+
79
+ end
80
+
81
+ private
82
+
83
+ def coords_from(x, y)
84
+ if y.nil?
85
+ point = x
86
+
87
+ unless point.respond_to?(:x) && point.respond_to?(:y)
88
+ raise ArgumentError, "expected #{point.inspect} to respond to :x and :y"
89
+ end
90
+
91
+ x, y = point.x, point.y
92
+ end
93
+
94
+ [Integer(x), Integer(y)]
95
+ end
96
+
97
+ def assert_element(element)
98
+ unless element.kind_of? Element
99
+ raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
100
+ end
101
+ end
102
+
103
+ end
104
+ end
105
+ end
@@ -413,6 +413,52 @@ module Selenium
413
413
  execute :dragElement, {:id => element}, :x => right_by, :y => down_by
414
414
  end
415
415
 
416
+ def touchSingleTap(element)
417
+ execute :touchSingleTap, {}, :element => element
418
+ end
419
+
420
+ def touchDoubleTap(element)
421
+ execute :touchDoubleTap, {}, :element => element
422
+ end
423
+
424
+ def touchLongPress(element)
425
+ execute :touchLongPress, {}, :element => element
426
+ end
427
+
428
+ def touchDown(x, y)
429
+ execute :touchDown, {}, :x => x, :y => y
430
+ end
431
+
432
+ def touchUp(x, y)
433
+ execute :touchUp, {}, :x => x, :y => y
434
+ end
435
+
436
+ def touchMove(x, y)
437
+ execute :touchMove, {}, :x => x, :y => y
438
+ end
439
+
440
+ def touchScroll(element, x, y)
441
+ if element
442
+ execute :touchScroll, {}, :xoffset => x, :yoffset => y
443
+ else
444
+ execute :touchScroll, {}, :element => element,
445
+ :xoffset => x,
446
+ :yoffset => y
447
+ end
448
+ end
449
+
450
+ def touchFlick(xspeed, yspeed)
451
+ execute :touchFlick, {}, :xspeed => xspeed, :yspeed => yspeed
452
+ end
453
+
454
+ def touchElementFlick(element, right_by, down_by, speed)
455
+ execute :touchFlick, {}, :element => element,
456
+ :xoffset => right_by,
457
+ :yoffset => down_by,
458
+ :speed => speed
459
+
460
+ end
461
+
416
462
  #
417
463
  # element properties
418
464
  #
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 2.18.0
4
+ prerelease: 7
5
+ version: 2.19.0.rc1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jari Bakken
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-01-27 00:00:00 +01:00
13
+ date: 2012-02-06 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -160,6 +160,8 @@ files:
160
160
  - lib/selenium/webdriver/common/socket_poller.rb
161
161
  - lib/selenium/webdriver/common/target_locator.rb
162
162
  - lib/selenium/webdriver/common/timeouts.rb
163
+ - lib/selenium/webdriver/common/touch_action_builder.rb
164
+ - lib/selenium/webdriver/common/touch_screen.rb
163
165
  - lib/selenium/webdriver/common/wait.rb
164
166
  - lib/selenium/webdriver/common/window.rb
165
167
  - lib/selenium/webdriver/common/zipper.rb
@@ -169,6 +171,7 @@ files:
169
171
  - lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb
170
172
  - lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb
171
173
  - lib/selenium/webdriver/common/driver_extensions/has_location.rb
174
+ - lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb
172
175
  - lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb
173
176
  - lib/selenium/webdriver/common/driver_extensions/rotatable.rb
174
177
  - lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb
@@ -229,9 +232,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
229
232
  required_rubygems_version: !ruby/object:Gem::Requirement
230
233
  none: false
231
234
  requirements:
232
- - - ">="
235
+ - - ">"
233
236
  - !ruby/object:Gem::Version
234
- version: "0"
237
+ version: 1.3.1
235
238
  requirements: []
236
239
 
237
240
  rubyforge_project: