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.
- data/.gitignore +2 -0
- data/.travis.yml +21 -0
- data/Appraisals +4 -4
- data/CONTRIBUTING.md +14 -3
- data/Gemfile +1 -1
- data/Gemfile.lock +27 -19
- data/NEWS.md +15 -0
- data/README.md +126 -76
- data/Vagrantfile +7 -0
- data/capybara-webkit.gemspec +3 -0
- data/gemfiles/2.0.gemfile +7 -0
- data/gemfiles/2.0.gemfile.lock +72 -0
- data/gemfiles/2.1.gemfile +7 -0
- data/gemfiles/2.1.gemfile.lock +71 -0
- data/lib/capybara/webkit/browser.rb +22 -22
- data/lib/capybara/webkit/connection.rb +9 -6
- data/lib/capybara/webkit/driver.rb +22 -6
- data/lib/capybara/webkit/errors.rb +25 -0
- data/lib/capybara/webkit/node.rb +36 -10
- data/lib/capybara/webkit/version.rb +1 -1
- data/spec/browser_spec.rb +16 -1
- data/spec/capybara_webkit_builder_spec.rb +9 -3
- data/spec/connection_spec.rb +19 -3
- data/spec/driver_spec.rb +324 -144
- data/spec/errors_spec.rb +11 -0
- data/spec/integration/session_spec.rb +244 -0
- data/spec/selenium_compatibility_spec.rb +3 -1
- data/spec/spec_helper.rb +1 -9
- data/src/Authenticate.cpp +3 -2
- data/src/ClearCookies.cpp +1 -1
- data/src/ClearPromptText.cpp +1 -1
- data/src/Command.cpp +8 -4
- data/src/Command.h +7 -4
- data/src/CommandFactory.cpp +4 -2
- data/src/CommandParser.cpp +1 -1
- data/src/Connection.cpp +4 -4
- data/src/ConsoleMessages.cpp +1 -1
- data/src/CurrentUrl.cpp +2 -2
- data/src/EnableLogging.cpp +1 -1
- data/src/ErrorMessage.cpp +26 -0
- data/src/ErrorMessage.h +21 -0
- data/src/Evaluate.cpp +1 -1
- data/src/Execute.cpp +3 -2
- data/src/FindCss.cpp +13 -0
- data/src/FindCss.h +11 -0
- data/src/FindXpath.cpp +13 -0
- data/src/FindXpath.h +11 -0
- data/src/FrameFocus.cpp +4 -3
- data/src/GetCookies.cpp +1 -1
- data/src/GetTimeout.cpp +1 -1
- data/src/GetWindowHandle.cpp +1 -1
- data/src/GetWindowHandles.cpp +1 -1
- data/src/Header.cpp +2 -2
- data/src/Headers.cpp +1 -6
- data/src/IgnoreSslErrors.cpp +1 -1
- data/src/InvocationResult.cpp +29 -0
- data/src/InvocationResult.h +16 -0
- data/src/JavascriptAlertMessages.cpp +1 -1
- data/src/JavascriptCommand.cpp +15 -0
- data/src/JavascriptCommand.h +20 -0
- data/src/JavascriptConfirmMessages.cpp +1 -1
- data/src/JavascriptInvocation.cpp +128 -1
- data/src/JavascriptInvocation.h +22 -1
- data/src/JavascriptPromptMessages.cpp +1 -1
- data/src/NetworkAccessManager.cpp +8 -16
- data/src/NetworkAccessManager.h +5 -11
- data/src/NetworkReplyProxy.cpp +91 -0
- data/src/NetworkReplyProxy.h +65 -0
- data/src/Node.cpp +4 -4
- data/src/Node.h +2 -2
- data/src/NullCommand.cpp +2 -1
- data/src/PageLoadingCommand.cpp +2 -1
- data/src/Render.cpp +1 -1
- data/src/Reset.cpp +1 -1
- data/src/ResizeWindow.cpp +1 -1
- data/src/Response.cpp +7 -0
- data/src/Response.h +8 -3
- data/src/SetConfirmAction.cpp +1 -1
- data/src/SetCookie.cpp +2 -2
- data/src/SetPromptAction.cpp +1 -1
- data/src/SetPromptText.cpp +1 -1
- data/src/SetProxy.cpp +2 -2
- data/src/SetSkipImageLoading.cpp +1 -1
- data/src/SetTimeout.cpp +3 -2
- data/src/SetUrlBlacklist.cpp +2 -2
- data/src/Status.cpp +1 -1
- data/src/TimeoutCommand.cpp +4 -2
- data/src/Title.cpp +11 -0
- data/src/Title.h +9 -0
- data/src/Version.cpp +13 -0
- data/src/Version.h +10 -0
- data/src/Visit.cpp +1 -1
- data/src/WebPage.cpp +49 -27
- data/src/WebPage.h +14 -7
- data/src/WebPageManager.cpp +10 -1
- data/src/WebPageManager.h +4 -1
- data/src/WindowFocus.cpp +3 -2
- data/src/body.cpp +3 -6
- data/src/capybara.js +103 -101
- data/src/find_command.h +4 -2
- data/src/main.cpp +1 -1
- data/src/stable.h +39 -0
- data/src/webkit_server.pro +26 -6
- data/vagrant_setup.sh +58 -0
- metadata +51 -78
- data/gemfiles/1.0.gemfile +0 -7
- data/gemfiles/1.0.gemfile.lock +0 -70
- data/gemfiles/1.1.gemfile +0 -7
- data/gemfiles/1.1.gemfile.lock +0 -70
- data/src/Find.cpp +0 -20
- data/src/Find.h +0 -11
data/.gitignore
CHANGED
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
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
|
-
|
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
data/Gemfile.lock
CHANGED
@@ -1,34 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
capybara-webkit (0.
|
4
|
+
capybara-webkit (1.0.0)
|
5
5
|
capybara (~> 2.0, >= 2.0.2)
|
6
6
|
json
|
7
7
|
|
8
8
|
GEM
|
9
|
-
remote:
|
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
|
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
|
-
|
20
|
-
|
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.
|
25
|
-
|
26
|
-
|
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.
|
31
|
-
rack (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.
|
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
|
-
|
49
|
-
|
50
|
-
rack (~> 1.
|
51
|
-
tilt (~> 1.
|
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.
|
54
|
-
websocket (1.0.
|
55
|
-
xpath (
|
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)
|
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
|
-
|
51
|
+
```ruby
|
52
|
+
gem "capybara-webkit"
|
53
|
+
```
|
51
54
|
|
52
55
|
Set your Capybara Javascript driver to webkit:
|
53
56
|
|
54
|
-
|
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
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
82
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
101
|
-
|
102
|
-
|
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
|
-
|
107
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
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
|
-
|
222
|
+
```ruby
|
223
|
+
page.driver.header 'Referer', 'https://www.thoughtbot.com'
|
224
|
+
```
|
175
225
|
|
176
226
|
Contributing
|
177
227
|
------------
|