cuprite 0.15.1 → 0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -13
- data/lib/capybara/cuprite/browser.rb +17 -6
- data/lib/capybara/cuprite/cookie.rb +1 -1
- data/lib/capybara/cuprite/driver.rb +2 -1
- data/lib/capybara/cuprite/javascripts/index.js +29 -0
- data/lib/capybara/cuprite/node.rb +9 -3
- data/lib/capybara/cuprite/page.rb +0 -1
- data/lib/capybara/cuprite/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70fb54b637d782b831b70e9894f65d95deb839abca0dff8355245c1dfaf7f81e
|
4
|
+
data.tar.gz: f909e93716a7bffb69e35cf4dbc783c13e4acc9d13a226f2ee5d85d2c49cc427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 521a59b3852efa9a3e770090e56bdcbc508da3465414bc2a72300f10757380103d9b6cb668a426d0af3173a89ad02f5cbf78666d9d33b19235d68f2e955182d4
|
7
|
+
data.tar.gz: dd50d8cd20886faa16e5372659c25792847286c954ea1c5a951b5a504d87cb06897e2e0bacd7d86457a6f72529054d99bc3773e163a06d926ef0c21a98cc7375
|
data/README.md
CHANGED
@@ -122,13 +122,17 @@ be automatically cleared at the end of the test.
|
|
122
122
|
|
123
123
|
## Network traffic
|
124
124
|
|
125
|
-
* `page.driver.network_traffic`
|
126
|
-
the current page. This returns an array of request objects.
|
125
|
+
* `page.driver.network_traffic` allows you to inspect network traffic (i.e., loaded resources) on the current page. It returns an array of `Ferrum::Network::Exchange` objects, each representing a network request/response exchange. You can query both the request and response details of each exchange.
|
127
126
|
|
128
127
|
```ruby
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
# Retrieve all network exchanges
|
129
|
+
network_traffic = page.driver.network_traffic
|
130
|
+
|
131
|
+
# Access the first exchange
|
132
|
+
first_exchange = network_traffic.first
|
133
|
+
|
134
|
+
# Inspect the response of the first request
|
135
|
+
response = first_exchange.response
|
132
136
|
```
|
133
137
|
|
134
138
|
* `page.driver.wait_for_network_idle` Natively waits for network idle and if
|
@@ -183,27 +187,29 @@ Besides capybara screenshot method you can get image as Base64:
|
|
183
187
|
|
184
188
|
## Proxy
|
185
189
|
|
186
|
-
* `page.driver.set_proxy(ip, port,
|
190
|
+
* `page.driver.set_proxy(ip, port, user, password)`
|
187
191
|
|
188
192
|
|
189
|
-
## URL
|
193
|
+
## URL Blocklisting & Allowlisting
|
190
194
|
|
191
|
-
Cuprite supports URL
|
195
|
+
Cuprite supports URL blocklisting, which allows you to prevent scripts from
|
192
196
|
running on designated domains:
|
193
197
|
|
194
198
|
```ruby
|
195
|
-
page.driver.browser.
|
199
|
+
page.driver.browser.url_blocklist = %r{http://www.example.com}
|
196
200
|
```
|
197
201
|
|
198
|
-
and also URL
|
202
|
+
and also URL allowlisting, which allows scripts to only run on designated
|
199
203
|
domains:
|
200
204
|
|
201
205
|
```ruby
|
202
|
-
page.driver.browser.
|
206
|
+
page.driver.browser.url_allowlist = %r{http://www.example.com}
|
203
207
|
```
|
204
208
|
|
205
|
-
|
206
|
-
|
209
|
+
For legacy support, `url_blacklist=` and `url_whitelist=` continue to work respectively.
|
210
|
+
|
211
|
+
If you are experiencing slower run times, consider creating a URL allowlist of
|
212
|
+
domains that are essential or a blocklist of domains that are not essential,
|
207
213
|
such as ad networks or analytics, to your testing environment.
|
208
214
|
|
209
215
|
## License
|
@@ -139,26 +139,33 @@ module Capybara
|
|
139
139
|
raise NotImplementedError
|
140
140
|
end
|
141
141
|
|
142
|
-
def drag(node, other, steps, delay = nil)
|
142
|
+
def drag(node, other, steps, delay = nil, scroll = true)
|
143
143
|
x1, y1 = node.find_position
|
144
|
-
x2, y2 = other.find_position
|
145
144
|
|
146
145
|
mouse.move(x: x1, y: y1)
|
147
146
|
mouse.down
|
148
147
|
sleep delay if delay
|
148
|
+
|
149
|
+
other.scroll_into_view if scroll
|
150
|
+
|
151
|
+
x2, y2 = other.find_position
|
149
152
|
mouse.move(x: x2, y: y2, steps: steps)
|
153
|
+
|
150
154
|
mouse.up
|
151
155
|
end
|
152
156
|
|
153
|
-
def drag_by(node,
|
157
|
+
def drag_by(node, dx, dy, steps, delay = nil, scroll = true)
|
154
158
|
x1, y1 = node.find_position
|
155
|
-
x2 = x1 + x
|
156
|
-
y2 = y1 + y
|
157
159
|
|
158
160
|
mouse.move(x: x1, y: y1)
|
159
161
|
mouse.down
|
162
|
+
|
160
163
|
sleep delay if delay
|
161
|
-
|
164
|
+
|
165
|
+
evaluate("window.scrollBy(#{dx}, #{dy})") if scroll # should be extracted to Mouse#scroll_by in ferrum
|
166
|
+
|
167
|
+
x2, y2 = node.find_position
|
168
|
+
mouse.move(x: x2 + dx, y: y2 + dy, steps: steps)
|
162
169
|
mouse.up
|
163
170
|
end
|
164
171
|
|
@@ -203,6 +210,10 @@ module Capybara
|
|
203
210
|
evaluate_on(node: node, expression: "_cuprite.path(this)")
|
204
211
|
end
|
205
212
|
|
213
|
+
def obscured?(node)
|
214
|
+
evaluate_on(node: node, expression: "_cuprite.isObscured(this)")
|
215
|
+
end
|
216
|
+
|
206
217
|
def all_text(node)
|
207
218
|
node.text
|
208
219
|
end
|
@@ -251,7 +251,8 @@ module Capybara
|
|
251
251
|
|
252
252
|
def remove_cookie(name, **options)
|
253
253
|
options[:domain] = default_domain if options.empty?
|
254
|
-
|
254
|
+
options = options.merge(name: name)
|
255
|
+
browser.cookies.remove(**options)
|
255
256
|
end
|
256
257
|
|
257
258
|
def clear_cookies
|
@@ -115,6 +115,35 @@ class Cuprite {
|
|
115
115
|
return `//${selectors.join("/")}`;
|
116
116
|
}
|
117
117
|
|
118
|
+
/**
|
119
|
+
* Returns true if the node is obscured in the viewport.
|
120
|
+
*
|
121
|
+
* @param {Element} node
|
122
|
+
* @return {boolean} true if the node is obscured, false otherwise
|
123
|
+
*/
|
124
|
+
isObscured(node) {
|
125
|
+
let win = window;
|
126
|
+
let rect = node.getBoundingClientRect();
|
127
|
+
let px = rect.left + rect.width / 2;
|
128
|
+
let py = rect.top + rect.height / 2;
|
129
|
+
|
130
|
+
while (win) {
|
131
|
+
let topNode = win.document.elementFromPoint(px, py);
|
132
|
+
|
133
|
+
if (node !== topNode && !node.contains(topNode)) return true;
|
134
|
+
|
135
|
+
node = win.frameElement;
|
136
|
+
if (!node) return false;
|
137
|
+
|
138
|
+
rect = node.getBoundingClientRect();
|
139
|
+
px = rect.left + px;
|
140
|
+
py = rect.top + py;
|
141
|
+
win = win.parent;
|
142
|
+
}
|
143
|
+
|
144
|
+
return false;
|
145
|
+
}
|
146
|
+
|
118
147
|
set(node, value) {
|
119
148
|
if (node.readOnly) return;
|
120
149
|
|
@@ -110,7 +110,7 @@ module Capybara
|
|
110
110
|
command(:set, value.to_s)
|
111
111
|
elsif self[:isContentEditable]
|
112
112
|
command(:delete_text)
|
113
|
-
|
113
|
+
click.type(value.to_s)
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
@@ -161,14 +161,16 @@ module Capybara
|
|
161
161
|
|
162
162
|
def drag_to(other, **options)
|
163
163
|
options[:steps] ||= 1
|
164
|
+
options[:scroll] = true unless options.key?(:scroll)
|
164
165
|
|
165
|
-
command(:drag, other.node, options[:steps], options[:delay])
|
166
|
+
command(:drag, other.node, options[:steps], options[:delay], options[:scroll])
|
166
167
|
end
|
167
168
|
|
168
169
|
def drag_by(x, y, **options)
|
169
170
|
options[:steps] ||= 1
|
171
|
+
options[:scroll] = true unless options.key?(:scroll)
|
170
172
|
|
171
|
-
command(:drag_by, x, y, options[:steps], options[:delay])
|
173
|
+
command(:drag_by, x, y, options[:steps], options[:delay], options[:scroll])
|
172
174
|
end
|
173
175
|
|
174
176
|
def trigger(event)
|
@@ -211,6 +213,10 @@ module Capybara
|
|
211
213
|
command(:path)
|
212
214
|
end
|
213
215
|
|
216
|
+
def obscured?
|
217
|
+
command(:obscured?)
|
218
|
+
end
|
219
|
+
|
214
220
|
def inspect
|
215
221
|
%(#<#{self.class} @node=#{@node.inspect}>)
|
216
222
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuprite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.16'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Vorotilin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.16.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.16.0
|
41
41
|
description: Cuprite is a driver for Capybara that allows you to run your tests on
|
42
42
|
a headless Chrome browser
|
43
43
|
email:
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
|
-
rubygems_version: 3.5.
|
85
|
+
rubygems_version: 3.5.22
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Headless Chrome driver for Capybara
|