Clarification on network.intercept
#381
Closed
decaffeinatedio
started this conversation in
General
Replies: 1 comment
-
You can have many blocks only if you handle them properly. There are additional arguments passed to the block browser = Ferrum::Browser.new
browser.network.intercept
browser.on(:request) do |request, index, total|
if request.match?(/bla-bla/)
request.abort
else
# This check allows to find if there's next block that can handle request
index + 1 < total ? next : request.continue
end
end
browser.on(:request) do |request, index, total|
if request.match?(/lorem/)
request.respond(body: "Lorem ipsum")
else
index + 1 < total ? next : request.continue
end
end
browser.go_to("https://www.google.com") Though it's not documented I believe. I wanted to add some easier public API but didn't have time. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Am I correct in understanding that there can only be a single
network.intercept
block per context? That is my takeaway from the following in the readme:But I'm not asking exclusively about the authorize case -- will having two network.intercept blocks operating on the same context cause unexpected behavior?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions