touch_action 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p547
data/CHANGELOG.md CHANGED
@@ -1,7 +1,10 @@
1
- ## v1.2.0
1
+ ## v1.3.0
2
2
 
3
- * added execution block until YUI is loaded and gesture is performed
4
- * added readyState checking in order to wait for pages to load when using tap on links for example
3
+ * stable version
4
+
5
+ ## v1.2.1
6
+
7
+ * unusable version
5
8
 
6
9
  ## v1.1.0
7
10
 
@@ -6,20 +6,8 @@ module TouchAction
6
6
  module RspecHelper
7
7
 
8
8
  def touch_action locator, *args
9
- page.driver.browser.manage.timeouts.script_timeout = 30
10
- page.driver.browser.execute_async_script( TouchAction::ScriptGenerator.yui_loader )
11
9
  final_script = TouchAction::ScriptGenerator.generate_javascript(*args)
12
- page.driver.browser.execute_async_script( final_script, locator )
13
- wait_for_page_ready_state
14
- end
15
-
16
- private
17
- def wait_for_page_ready_state
18
- sleep(0.5) # mobile browsers wait around 300ms when tapping to check if it isn's a double tap before triggering the link
19
- end_time = Time.now + 30
20
- while (page.driver.browser.execute_script('return document.readyState' != 'complete') || Time.now > end_time)
21
- sleep(0.1)
22
- end
10
+ page.driver.browser.execute_script( final_script, locator )
23
11
  end
24
12
 
25
13
  end
@@ -1,15 +1,38 @@
1
1
  (function( touch_action, $, undefined ) {
2
2
 
3
- touch_action.perform_gesture = function(selenium_finalized_callback) {
4
-
3
+ // private property
4
+ var execute_gesture = function() {
5
5
  YUI().use('node-event-simulate', function(Y) {
6
6
 
7
7
  var node = Y.one(touch_action.element);
8
8
  node.simulateGesture(touch_action.gesture, touch_action.options);
9
9
 
10
- });
10
+ });
11
+ };
12
+
13
+ // private method
14
+ function loadYui() {
15
+
16
+ var head = document.getElementsByTagName('head')[0];
17
+ var script = document.createElement('script');
18
+ script.type = 'text/javascript';
19
+ script.src = "//yui.yahooapis.com/3.18.1/build/yui/yui-min.js";
20
+
21
+ script.onreadystatechange = execute_gesture;
22
+ script.onload = execute_gesture;
23
+
24
+ head.appendChild(script);
25
+
26
+ };
27
+ // public method
28
+ touch_action.perform = function() {
29
+
30
+ if (typeof YUI == 'undefined') {
31
+ loadYui();
32
+ } else {
33
+ execute_gesture();
34
+ };
11
35
 
12
- selenium_finalized_callback();
13
36
  };
14
37
 
15
38
 
@@ -21,4 +44,4 @@ touch_action.gesture = "<%=gesture%>";
21
44
 
22
45
  touch_action.options = <%=options.to_json%>;
23
46
 
24
- touch_action.perform_gesture(arguments[arguments.length - 1]);
47
+ touch_action.perform();
@@ -13,10 +13,6 @@ module TouchAction
13
13
  rotate: {rotation: -75}
14
14
  }
15
15
 
16
- def self.yui_loader
17
- yui_loader_script = File.read(File.expand_path("../javascripts/yui_loader.js", __FILE__))
18
- end
19
-
20
16
  def self.generate_javascript action, options = {}
21
17
  action = :flick if action == :swipe
22
18
  raise ArgumentError, "The touch action #{action} doesn't exist" unless ACTIONS_WITH_DEFAULT_OPTIONS[action]
@@ -5,21 +5,8 @@ module TouchAction
5
5
  module SeleniumWebdriver
6
6
 
7
7
  def touch_action *args
8
- Selenium::WebDriver::Timeouts.new(bridge).script_timeout= 30
9
- bridge.executeAsyncScript( TouchAction::ScriptGenerator.yui_loader )
10
8
  final_script = TouchAction::ScriptGenerator.generate_javascript(*args)
11
- bridge.executeAsyncScript( final_script, self )
12
- wait_for_page_ready_state
13
- end
14
-
15
- private
16
-
17
- def wait_for_page_ready_state
18
- sleep(0.5) # mobile browsers wait around 300ms when tapping to check if it isn's a double tap before triggering the link
19
- end_time = Time.now + 30
20
- while (bridge.executeScript('return document.readyState' != 'complete') || Time.now > end_time)
21
- sleep(0.1)
22
- end
9
+ bridge.executeScript( final_script, self )
23
10
  end
24
11
 
25
12
  end
@@ -1,3 +1,3 @@
1
1
  module TouchAction
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -3,21 +3,9 @@ require "touch_action/script_generator"
3
3
 
4
4
  module TouchAction
5
5
  module WatirWebdriver
6
-
7
6
  def touch_action *args
8
- browser.driver.manage.timeouts.script_timeout = 30
9
- browser.driver.execute_async_script( TouchAction::ScriptGenerator.yui_loader )
10
7
  final_script = TouchAction::ScriptGenerator.generate_javascript(*args)
11
- browser.driver.execute_async_script( final_script, self.wd )
12
- wait_for_page_ready_state
13
- end
14
-
15
-
16
- private
17
-
18
- def wait_for_page_ready_state
19
- sleep(0.5) # mobile browsers wait around 300ms when tapping to check if it isn's a double tap before triggering the link
20
- browser.wait(60)
8
+ browser.execute_script( final_script, self )
21
9
  end
22
10
  end
23
11
 
@@ -6,27 +6,23 @@ RSpec.describe TouchAction do
6
6
  @browser.goto('http://localhost:9292/tap')
7
7
  element = @browser.div(id: 'myElement')
8
8
  element.touch_action :tap
9
+ sleep(5)
9
10
  expect(element.text).to include('tap')
10
11
  end
11
12
 
12
13
  it 'should tap link bound by FastClick' do
13
14
  @browser.goto('http://localhost:9292/tap')
14
15
  @browser.a(id: 'fastclick').touch_action :tap
16
+ sleep(5)
15
17
  expect(@browser.p(id: 'fast-click-test').text).to include('1 times')
16
18
  end
17
19
 
18
20
  it "should tap using webdriver capybara", js: true, use_webdriver: :capybara do
19
21
  visit('http://localhost:9292/tap')
20
22
  touch_action '#myElement', :tap
23
+ sleep(5)
21
24
  expect(find("#myElement").text).to include('tap')
22
25
  end
23
26
 
24
- it "should tap using selenium", js: true, use_webdriver: :selenium do
25
- @browser.navigate.to('http://localhost:9292/tap')
26
- element = @browser.find_element(:id, 'myElement')
27
- element.touch_action :tap
28
- expect(element.text).to include('tap')
29
- end
30
-
31
27
  end
32
28
  end
data/spec/spec_helper.rb CHANGED
@@ -19,7 +19,7 @@ when 'ios'
19
19
  capabilities = {
20
20
  :deviceName => 'iPhone 5s',
21
21
  :browserName => 'Safari',
22
- :platformVersion => '8.1',
22
+ :platformVersion => '8.2',
23
23
  :platformName => 'iOS',
24
24
  :app => 'safari',
25
25
  :newCommandTimeout => 9999
metadata CHANGED
@@ -1,125 +1,142 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: touch_action
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Ricardo Nacif
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-01-08 00:00:00.000000000 Z
12
+ date: 2015-04-11 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: watir-webdriver
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - ">="
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - ">="
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: capybara
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: bundler
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - "~>"
51
+ - - ~>
46
52
  - !ruby/object:Gem::Version
47
53
  version: '1.7'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - "~>"
59
+ - - ~>
53
60
  - !ruby/object:Gem::Version
54
61
  version: '1.7'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rake
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - "~>"
67
+ - - ~>
60
68
  - !ruby/object:Gem::Version
61
69
  version: '10.0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - "~>"
75
+ - - ~>
67
76
  - !ruby/object:Gem::Version
68
77
  version: '10.0'
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: pry
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - ">="
83
+ - - ! '>='
74
84
  - !ruby/object:Gem::Version
75
85
  version: '0'
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - ">="
91
+ - - ! '>='
81
92
  - !ruby/object:Gem::Version
82
93
  version: '0'
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: rack
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - ">="
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - ">="
107
+ - - ! '>='
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: rspec
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
- - - "~>"
115
+ - - ~>
102
116
  - !ruby/object:Gem::Version
103
117
  version: 3.1.0
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
- - - "~>"
123
+ - - ~>
109
124
  - !ruby/object:Gem::Version
110
125
  version: 3.1.0
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: thin
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
- - - ">="
131
+ - - ! '>='
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
- - - ">="
139
+ - - ! '>='
123
140
  - !ruby/object:Gem::Version
124
141
  version: '0'
125
142
  description: Adds touch gestures simulation to Watir, Selenium and Capybara using
@@ -130,8 +147,9 @@ executables: []
130
147
  extensions: []
131
148
  extra_rdoc_files: []
132
149
  files:
133
- - ".gitignore"
134
- - ".travis.yml"
150
+ - .gitignore
151
+ - .ruby-version
152
+ - .travis.yml
135
153
  - CHANGELOG.md
136
154
  - Gemfile
137
155
  - LICENSE.txt
@@ -141,7 +159,6 @@ files:
141
159
  - lib/touch_action.rb
142
160
  - lib/touch_action/capybara_rspec_helper.rb
143
161
  - lib/touch_action/javascripts/touch_action.js.erb
144
- - lib/touch_action/javascripts/yui_loader.js
145
162
  - lib/touch_action/script_generator.rb
146
163
  - lib/touch_action/selenium-webdriver.rb
147
164
  - lib/touch_action/version.rb
@@ -173,26 +190,27 @@ files:
173
190
  homepage: https://github.com/Ricardonacif/touch_action
174
191
  licenses:
175
192
  - MIT
176
- metadata: {}
177
193
  post_install_message:
178
194
  rdoc_options: []
179
195
  require_paths:
180
196
  - lib
181
197
  required_ruby_version: !ruby/object:Gem::Requirement
198
+ none: false
182
199
  requirements:
183
- - - ">="
200
+ - - ! '>='
184
201
  - !ruby/object:Gem::Version
185
202
  version: '0'
186
203
  required_rubygems_version: !ruby/object:Gem::Requirement
204
+ none: false
187
205
  requirements:
188
- - - ">="
206
+ - - ! '>='
189
207
  - !ruby/object:Gem::Version
190
208
  version: '0'
191
209
  requirements: []
192
210
  rubyforge_project:
193
- rubygems_version: 2.2.2
211
+ rubygems_version: 1.8.23.2
194
212
  signing_key:
195
- specification_version: 4
213
+ specification_version: 3
196
214
  summary: Adds touch gestures simulation to Watir-WebDriver, Selenium-WebDriver and
197
215
  Capybara using YUI JS.
198
216
  test_files:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: bfa947340d9b1adb9be7ed82fd79ecd464c860b5
4
- data.tar.gz: 8cbef3fbadc44447983247c002980644a58d12b6
5
- SHA512:
6
- metadata.gz: 95c7a7bd87ef4983362ee27d2d27cdd16f3973772dc0f6a72d3aceb595eb0948b28ee53450c6e1a83c125955c392c0676a37061f72b5911f79e22f8783412950
7
- data.tar.gz: 85d7accb204826af76f47dcba3429629e9593130ca3e9bd3ed5f4b5f01faef22473664a0e888953b7c43aa08eaf408d8f479742e7961b97b69178c3f34f8739b
@@ -1,22 +0,0 @@
1
- (function(callback) {
2
- if (typeof YUI == 'undefined') {
3
- var script = document.createElement('script');
4
- var head = document.getElementsByTagName('head')[0];
5
- var done = false;
6
- script.onload = script.onreadystatechange = (function() {
7
- if (!done && (!this.readyState || this.readyState == 'loaded'
8
- || this.readyState == 'complete')) {
9
- done = true;
10
- script.onload = script.onreadystatechange = null;
11
- head.removeChild(script);
12
- callback();
13
- }
14
- });
15
- script.type = 'text/javascript';
16
- script.src = "//yui.yahooapis.com/3.18.1/build/yui/yui-min.js";
17
- head.appendChild(script);
18
- }
19
- else {
20
- callback();
21
- }
22
- })(arguments[arguments.length - 1]);