Skip to content

Commit 3a2dc27

Browse files
committed
Accept dialog by default if user didn't provide callback
1 parent 006c5fc commit 3a2dc27

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

bin/console

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env ruby
22

3+
lib = File.expand_path("../lib", __dir__)
4+
$:.unshift(lib) unless $:.include?(lib)
5+
36
require "irb"
47
require "irb/completion"
58
require "ferrum"

lib/ferrum/page.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ def subscribe
218218
Thread.main.raise JavaScriptError.new(params.dig("exceptionDetails", "exception"))
219219
end
220220
end
221+
222+
on(:dialog) do |dialog, index, total|
223+
if total == 1
224+
warn "Dialog was shown but you didn't provide `on(:dialog)` callback, accepting it by default. " \
225+
"Please take a look at https://github.com/rubycdp/ferrum#dialog"
226+
dialog.accept
227+
end
228+
end
221229
end
222230

223231
def prepare_page

0 commit comments

Comments
 (0)