capybara-webkit 0.14.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +21 -0
  3. data/Appraisals +4 -4
  4. data/CONTRIBUTING.md +14 -3
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +27 -19
  7. data/NEWS.md +15 -0
  8. data/README.md +126 -76
  9. data/Vagrantfile +7 -0
  10. data/capybara-webkit.gemspec +3 -0
  11. data/gemfiles/2.0.gemfile +7 -0
  12. data/gemfiles/2.0.gemfile.lock +72 -0
  13. data/gemfiles/2.1.gemfile +7 -0
  14. data/gemfiles/2.1.gemfile.lock +71 -0
  15. data/lib/capybara/webkit/browser.rb +22 -22
  16. data/lib/capybara/webkit/connection.rb +9 -6
  17. data/lib/capybara/webkit/driver.rb +22 -6
  18. data/lib/capybara/webkit/errors.rb +25 -0
  19. data/lib/capybara/webkit/node.rb +36 -10
  20. data/lib/capybara/webkit/version.rb +1 -1
  21. data/spec/browser_spec.rb +16 -1
  22. data/spec/capybara_webkit_builder_spec.rb +9 -3
  23. data/spec/connection_spec.rb +19 -3
  24. data/spec/driver_spec.rb +324 -144
  25. data/spec/errors_spec.rb +11 -0
  26. data/spec/integration/session_spec.rb +244 -0
  27. data/spec/selenium_compatibility_spec.rb +3 -1
  28. data/spec/spec_helper.rb +1 -9
  29. data/src/Authenticate.cpp +3 -2
  30. data/src/ClearCookies.cpp +1 -1
  31. data/src/ClearPromptText.cpp +1 -1
  32. data/src/Command.cpp +8 -4
  33. data/src/Command.h +7 -4
  34. data/src/CommandFactory.cpp +4 -2
  35. data/src/CommandParser.cpp +1 -1
  36. data/src/Connection.cpp +4 -4
  37. data/src/ConsoleMessages.cpp +1 -1
  38. data/src/CurrentUrl.cpp +2 -2
  39. data/src/EnableLogging.cpp +1 -1
  40. data/src/ErrorMessage.cpp +26 -0
  41. data/src/ErrorMessage.h +21 -0
  42. data/src/Evaluate.cpp +1 -1
  43. data/src/Execute.cpp +3 -2
  44. data/src/FindCss.cpp +13 -0
  45. data/src/FindCss.h +11 -0
  46. data/src/FindXpath.cpp +13 -0
  47. data/src/FindXpath.h +11 -0
  48. data/src/FrameFocus.cpp +4 -3
  49. data/src/GetCookies.cpp +1 -1
  50. data/src/GetTimeout.cpp +1 -1
  51. data/src/GetWindowHandle.cpp +1 -1
  52. data/src/GetWindowHandles.cpp +1 -1
  53. data/src/Header.cpp +2 -2
  54. data/src/Headers.cpp +1 -6
  55. data/src/IgnoreSslErrors.cpp +1 -1
  56. data/src/InvocationResult.cpp +29 -0
  57. data/src/InvocationResult.h +16 -0
  58. data/src/JavascriptAlertMessages.cpp +1 -1
  59. data/src/JavascriptCommand.cpp +15 -0
  60. data/src/JavascriptCommand.h +20 -0
  61. data/src/JavascriptConfirmMessages.cpp +1 -1
  62. data/src/JavascriptInvocation.cpp +128 -1
  63. data/src/JavascriptInvocation.h +22 -1
  64. data/src/JavascriptPromptMessages.cpp +1 -1
  65. data/src/NetworkAccessManager.cpp +8 -16
  66. data/src/NetworkAccessManager.h +5 -11
  67. data/src/NetworkReplyProxy.cpp +91 -0
  68. data/src/NetworkReplyProxy.h +65 -0
  69. data/src/Node.cpp +4 -4
  70. data/src/Node.h +2 -2
  71. data/src/NullCommand.cpp +2 -1
  72. data/src/PageLoadingCommand.cpp +2 -1
  73. data/src/Render.cpp +1 -1
  74. data/src/Reset.cpp +1 -1
  75. data/src/ResizeWindow.cpp +1 -1
  76. data/src/Response.cpp +7 -0
  77. data/src/Response.h +8 -3
  78. data/src/SetConfirmAction.cpp +1 -1
  79. data/src/SetCookie.cpp +2 -2
  80. data/src/SetPromptAction.cpp +1 -1
  81. data/src/SetPromptText.cpp +1 -1
  82. data/src/SetProxy.cpp +2 -2
  83. data/src/SetSkipImageLoading.cpp +1 -1
  84. data/src/SetTimeout.cpp +3 -2
  85. data/src/SetUrlBlacklist.cpp +2 -2
  86. data/src/Status.cpp +1 -1
  87. data/src/TimeoutCommand.cpp +4 -2
  88. data/src/Title.cpp +11 -0
  89. data/src/Title.h +9 -0
  90. data/src/Version.cpp +13 -0
  91. data/src/Version.h +10 -0
  92. data/src/Visit.cpp +1 -1
  93. data/src/WebPage.cpp +49 -27
  94. data/src/WebPage.h +14 -7
  95. data/src/WebPageManager.cpp +10 -1
  96. data/src/WebPageManager.h +4 -1
  97. data/src/WindowFocus.cpp +3 -2
  98. data/src/body.cpp +3 -6
  99. data/src/capybara.js +103 -101
  100. data/src/find_command.h +4 -2
  101. data/src/main.cpp +1 -1
  102. data/src/stable.h +39 -0
  103. data/src/webkit_server.pro +26 -6
  104. data/vagrant_setup.sh +58 -0
  105. metadata +51 -78
  106. data/gemfiles/1.0.gemfile +0 -7
  107. data/gemfiles/1.0.gemfile.lock +0 -70
  108. data/gemfiles/1.1.gemfile +0 -7
  109. data/gemfiles/1.1.gemfile.lock +0 -70
  110. data/src/Find.cpp +0 -20
  111. data/src/Find.h +0 -11
data/.gitignore CHANGED
@@ -18,3 +18,5 @@ tmp
18
18
  .rvmrc
19
19
  src/debug
20
20
  webkit_server.pro.user
21
+ .vagrant
22
+ *.gch
data/.travis.yml CHANGED
@@ -1,10 +1,31 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
+ - 2.0.0
4
5
  - rbx-19mode
5
6
  matrix:
6
7
  allow_failures:
7
8
  - rvm: rbx-19mode
9
+ exclude:
10
+ - rvm: 1.9.3
11
+ gemfile: gemfiles/2.0.gemfile
12
+ env: QMAKE=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake
13
+ - rvm: 2.0.0
14
+ gemfile: gemfiles/2.0.gemfile
15
+ env: QMAKE=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake
16
+ - rvm: rbx-19mode
17
+ gemfile: gemfiles/2.0.gemfile
18
+ env: QMAKE=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake
8
19
  notifications:
9
20
  email: false
10
21
  script: xvfb-run rake
22
+ env:
23
+ - QMAKE=/usr/bin/qmake
24
+ - QMAKE=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake
25
+ gemfile:
26
+ - gemfiles/2.0.gemfile
27
+ - gemfiles/2.1.gemfile
28
+ before_install:
29
+ - sudo apt-add-repository -y ppa:canonical-qt5-edgers/qt5-proper
30
+ - sudo apt-get update
31
+ - sudo apt-get install libqt5webkit5-dev qtdeclarative5-dev qtlocation5-dev qtsensors5-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
data/Appraisals CHANGED
@@ -1,7 +1,7 @@
1
- appraise "1.0" do
2
- gem "capybara", "~> 1.0.0"
1
+ appraise "2.0" do
2
+ gem "capybara", "~> 2.0.2"
3
3
  end
4
4
 
5
- appraise "1.1" do
6
- gem "capybara", "~> 1.1.0"
5
+ appraise "2.1" do
6
+ gem "capybara", "~> 2.1.0"
7
7
  end
data/CONTRIBUTING.md CHANGED
@@ -1,13 +1,24 @@
1
1
  We love pull requests. Here's a quick guide:
2
2
 
3
- Dependencies
3
+ ## Dependencies
4
4
 
5
5
  Some of the tests depend on the `identify` command that comes with Imagemagick.
6
- Imagemagick can be installed via [homebrew](http://mxcl.github.com/homebrew/).
6
+ Imagemagick can be installed via [homebrew](http://mxcl.github.com/homebrew/) on
7
+ Mac OS X:
7
8
 
8
9
  brew install imagemagick
9
10
 
10
- Contributing
11
+ If you prefer, you can use a [Vagrant](http://www.vagrantup.com/) virtual
12
+ machine. The Vagrantfile in the capybara-webkit repository will get you up and
13
+ running with all the development dependencies:
14
+
15
+ gem install vagrant
16
+ vagrant up
17
+ vagrant ssh
18
+ cd /vagrant
19
+ rake
20
+
21
+ ## Contributing
11
22
 
12
23
  1. Fork the repo.
13
24
 
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/Gemfile.lock CHANGED
@@ -1,34 +1,40 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capybara-webkit (0.14.2)
4
+ capybara-webkit (1.0.0)
5
5
  capybara (~> 2.0, >= 2.0.2)
6
6
  json
7
7
 
8
8
  GEM
9
- remote: http://rubygems.org/
9
+ remote: https://rubygems.org/
10
10
  specs:
11
+ addressable (2.3.2)
11
12
  appraisal (0.4.0)
12
13
  bundler
13
14
  rake
14
- capybara (2.0.2)
15
+ capybara (2.1.0)
15
16
  mime-types (>= 1.16)
16
17
  nokogiri (>= 1.3.3)
17
18
  rack (>= 1.0.0)
18
19
  rack-test (>= 0.5.4)
19
- selenium-webdriver (~> 2.0)
20
- xpath (~> 1.0.0)
21
- childprocess (0.3.7)
20
+ xpath (~> 2.0)
21
+ childprocess (0.3.6)
22
22
  ffi (~> 1.0, >= 1.0.6)
23
23
  diff-lcs (1.1.2)
24
- ffi (1.3.1)
25
- json (1.7.6)
26
- mime-types (1.20.1)
24
+ ffi (1.2.0)
25
+ ffi (1.2.0-x86-mingw32)
26
+ json (1.8.0)
27
+ libwebsocket (0.1.7.1)
28
+ addressable
29
+ websocket
30
+ mime-types (1.22)
27
31
  mini_magick (3.2.1)
28
32
  subexec (~> 0.0.4)
29
33
  multi_json (1.5.0)
30
- nokogiri (1.5.6)
31
- rack (1.4.1)
34
+ nokogiri (1.5.9)
35
+ rack (1.5.2)
36
+ rack-protection (1.3.2)
37
+ rack
32
38
  rack-test (0.6.2)
33
39
  rack (>= 1.0)
34
40
  rake (0.9.2)
@@ -41,18 +47,19 @@ GEM
41
47
  diff-lcs (~> 1.1.2)
42
48
  rspec-mocks (2.6.0)
43
49
  rubyzip (0.9.9)
44
- selenium-webdriver (2.29.0)
50
+ selenium-webdriver (2.27.2)
45
51
  childprocess (>= 0.2.5)
52
+ libwebsocket (~> 0.1.3)
46
53
  multi_json (~> 1.0)
47
54
  rubyzip
48
- websocket (~> 1.0.4)
49
- sinatra (1.1.2)
50
- rack (~> 1.1)
51
- tilt (~> 1.2)
55
+ sinatra (1.3.5)
56
+ rack (~> 1.4)
57
+ rack-protection (~> 1.3)
58
+ tilt (~> 1.3, >= 1.3.3)
52
59
  subexec (0.0.4)
53
- tilt (1.2.2)
54
- websocket (1.0.7)
55
- xpath (1.0.0)
60
+ tilt (1.3.3)
61
+ websocket (1.0.6)
62
+ xpath (2.0.0)
56
63
  nokogiri (~> 1.3)
57
64
 
58
65
  PLATFORMS
@@ -65,4 +72,5 @@ DEPENDENCIES
65
72
  mini_magick
66
73
  rake
67
74
  rspec (~> 2.6.0)
75
+ selenium-webdriver
68
76
  sinatra
data/NEWS.md CHANGED
@@ -1,3 +1,18 @@
1
+ New for 1.0.0:
2
+
3
+ * Fix a memory leak in the logger.
4
+ * Add Vagrant configuration.
5
+ * Deprecate the stdout option for Connection.
6
+ * Make Node#text work for svg elements.
7
+ * Add Driver#version to print version info.
8
+ * Click elements with native events.
9
+ * Fix test failures from warnings.
10
+ * Capybara 2.1 compatibility.
11
+ * Implement right click.
12
+ * Qt 5 compatibility.
13
+ * Set text fields using native key events.
14
+ * Clear localStorage on reset.
15
+
1
16
  New for 0.14.1:
2
17
 
3
18
  * Rescue from Errno::ESRCH in the exit hook in case webkit_server has already ended.
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  capybara-webkit
2
2
  ===============
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/thoughtbot/capybara-webkit.png?branch=master)](https://travis-ci.org/thoughtbot/capybara-webkit) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/thoughtbot/capybara-webkit)
4
+ [![Build Status](https://secure.travis-ci.org/thoughtbot/capybara-webkit.png?branch=master)](https://travis-ci.org/thoughtbot/capybara-webkit)
5
+ [![Code Climate](https://codeclimate.com/github/thoughtbot/capybara-webkit.png)](https://codeclimate.com/github/thoughtbot/capybara-webkit)
5
6
 
6
7
  A [capybara](https://github.com/jnicklas/capybara) driver that uses [WebKit](http://webkit.org) via [QtWebKit](http://doc.qt.nokia.com/4.7/qtwebkit.html).
7
8
 
@@ -47,11 +48,15 @@ Usage
47
48
 
48
49
  Add the capybara-webkit gem to your Gemfile:
49
50
 
50
- gem "capybara-webkit"
51
+ ```ruby
52
+ gem "capybara-webkit"
53
+ ```
51
54
 
52
55
  Set your Capybara Javascript driver to webkit:
53
56
 
54
- Capybara.javascript_driver = :webkit
57
+ ```ruby
58
+ Capybara.javascript_driver = :webkit
59
+ ```
55
60
 
56
61
  In cucumber, tag scenarios with @javascript to run them using a headless WebKit browser.
57
62
 
@@ -61,7 +66,9 @@ Take note of the transactional fixtures section of the [capybara README](https:/
61
66
 
62
67
  If you're using capybara-webkit with Sinatra, don't forget to set
63
68
 
64
- Capybara.app = MySinatraApp.new
69
+ ```ruby
70
+ Capybara.app = MySinatraApp.new
71
+ ```
65
72
 
66
73
  Non-Standard Driver Methods
67
74
  ---------------------------
@@ -70,108 +77,151 @@ capybara-webkit supports a few methods that are not part of the standard capybar
70
77
 
71
78
  **console_messages**: returns an array of messages printed using console.log
72
79
 
73
- # In Javascript:
74
- console.log("hello")
75
- # In Ruby:
76
- page.driver.console_messages
77
- => {:source=>"http://example.com", :line_number=>1, :message=>"hello"}
80
+ ```js
81
+ // In Javascript:
82
+ console.log("hello")
83
+ ```
84
+
85
+ ```ruby
86
+ # In Ruby:
87
+ page.driver.console_messages
88
+ => {:source=>"http://example.com", :line_number=>1, :message=>"hello"}
89
+ ```
78
90
 
79
91
  **error_messages**: returns an array of Javascript errors that occurred
80
92
 
81
- page.driver.error_messages
82
- => {:source=>"http://example.com", :line_number=>1, :message=>"SyntaxError: Parse error"}
93
+ ```ruby
94
+ page.driver.error_messages
95
+ => {:source=>"http://example.com", :line_number=>1, :message=>"SyntaxError: Parse error"}
96
+ ```
83
97
 
84
98
  **alert_messages, confirm_messages, prompt_messages**: returns arrays of Javascript dialog messages for each dialog type
85
99
 
86
- # In Javascript:
87
- alert("HI");
88
- confirm("Ok?");
89
- prompt("Number?", "42");
90
- # In Ruby:
91
- page.driver.alert_messages
92
- => ["Hi"]
93
- page.driver.confirm_messages
94
- => ["Ok?"]
95
- page.driver.prompt_messages
96
- => ["Number?"]
100
+ ```js
101
+ // In Javascript:
102
+ alert("HI");
103
+ confirm("Ok?");
104
+ prompt("Number?", "42");
105
+ ```
106
+
107
+ ```ruby
108
+ # In Ruby:
109
+ page.driver.alert_messages
110
+ => ["Hi"]
111
+ page.driver.confirm_messages
112
+ => ["Ok?"]
113
+ page.driver.prompt_messages
114
+ => ["Number?"]
115
+ ```
97
116
 
98
117
  **resize_window**: change the viewport size to the given width and height
99
118
 
100
- page.driver.resize_window(500, 300)
101
- page.driver.evaluate_script("window.innerWidth")
102
- => 500
119
+ ```ruby
120
+ page.driver.resize_window(500, 300)
121
+ page.driver.evaluate_script("window.innerWidth")
122
+ => 500
123
+ ```
103
124
 
104
125
  **cookies**: allows read-only access of cookies for the current session
105
126
 
106
- page.driver.cookies["alpha"]
107
- => "abc"
127
+ ```ruby
128
+ page.driver.cookies["alpha"]
129
+ => "abc"
130
+ ```
108
131
 
109
132
  **accept_js_confirms!**: accept any Javascript confirm that is triggered by the page's Javascript
110
133
 
111
- # In Javascript:
112
- if (confirm("Ok?"))
113
- console.log("Hi");
114
- else
115
- console.log("Bye");
116
- # In Ruby:
117
- page.driver.accept_js_confirms!
118
- visit "/"
119
- page.driver.console_messages.first[:message]
120
- => "Hi"
134
+ ```js
135
+ // In Javascript:
136
+ if (confirm("Ok?"))
137
+ console.log("Hi");
138
+ else
139
+ console.log("Bye");
140
+ ```
141
+
142
+ ```ruby
143
+ # In Ruby:
144
+ page.driver.accept_js_confirms!
145
+ visit "/"
146
+ page.driver.console_messages.first[:message]
147
+ => "Hi"
148
+ ```
121
149
 
122
150
  **dismiss_js_confirms!**: dismiss any Javascript confirm that is triggered by the page's Javascript
123
151
 
124
- # In Javascript:
125
- if (confirm("Ok?"))
126
- console.log("Hi");
127
- else
128
- console.log("Bye");
129
- # In Ruby:
130
- page.driver.dismiss_js_confirms!
131
- visit "/"
132
- page.driver.console_messages.first[:message]
133
- => "Bye"
152
+ ```js
153
+ // In Javascript:
154
+ if (confirm("Ok?"))
155
+ console.log("Hi");
156
+ else
157
+ console.log("Bye");
158
+ ```
159
+
160
+ ```ruby
161
+ # In Ruby:
162
+ page.driver.dismiss_js_confirms!
163
+ visit "/"
164
+ page.driver.console_messages.first[:message]
165
+ => "Bye"
166
+ ```
134
167
 
135
168
  **accept_js_prompts!**: accept any Javascript prompt that is triggered by the page's Javascript
136
169
 
137
- # In Javascript:
138
- var a = prompt("Number?", "0")
139
- console.log(a);
140
- # In Ruby:
141
- page.driver.accept_js_prompts!
142
- visit "/"
143
- page.driver.console_messages.first[:message]
144
- => "0"
170
+ ```js
171
+ // In Javascript:
172
+ var a = prompt("Number?", "0")
173
+ console.log(a);
174
+ ```
175
+
176
+ ```ruby
177
+ # In Ruby:
178
+ page.driver.accept_js_prompts!
179
+ visit "/"
180
+ page.driver.console_messages.first[:message]
181
+ => "0"
182
+ ```
145
183
 
146
184
  **dismiss_js_prompts!**: dismiss any Javascript prompt that is triggered by the page's Javascript
147
185
 
148
- # In Javascript:
149
- var a = prompt("Number?", "0")
150
- if (a != null)
151
- console.log(a);
152
- else
153
- console.log("you said no"));
154
- # In Ruby:
155
- page.driver.dismiss_js_prompts!
156
- visit "/"
157
- page.driver.console_messages.first[:message]
158
- => "you said no"
186
+ ```js
187
+ // In Javascript:
188
+ var a = prompt("Number?", "0")
189
+ if (a != null)
190
+ console.log(a);
191
+ else
192
+ console.log("you said no"));
193
+ ```
194
+
195
+ ```ruby
196
+ # In Ruby:
197
+ page.driver.dismiss_js_prompts!
198
+ visit "/"
199
+ page.driver.console_messages.first[:message]
200
+ => "you said no"
201
+ ```
159
202
 
160
203
  **js_prompt_input=(value)**: set the text to use if a Javascript prompt is encountered and accepted
161
204
 
162
- # In Javascript:
163
- var a = prompt("Number?", "0")
164
- console.log(a);
165
- # In Ruby:
166
- page.driver.js_prompt_input = "42"
167
- page.driver.accept_js_prompts!
168
- visit "/"
169
- page.driver.console_messages.first[:message]
170
- => "42"
205
+ ```js
206
+ // In Javascript:
207
+ var a = prompt("Number?", "0")
208
+ console.log(a);
209
+ ```
210
+
211
+ ```ruby
212
+ # In Ruby:
213
+ page.driver.js_prompt_input = "42"
214
+ page.driver.accept_js_prompts!
215
+ visit "/"
216
+ page.driver.console_messages.first[:message]
217
+ => "42"
218
+ ```
171
219
 
172
220
  **header**: set the given HTTP header for subsequent requests
173
221
 
174
- page.driver.header 'Referer', 'https://www.thoughtbot.com'
222
+ ```ruby
223
+ page.driver.header 'Referer', 'https://www.thoughtbot.com'
224
+ ```
175
225
 
176
226
  Contributing
177
227
  ------------