Skip to content

Commit 6d9b638

Browse files
authored
Merge pull request #215 from rubycdp/ferrum-timeout-per-page
feat: add timeout accessor per page
2 parents 42728ae + 682c723 commit 6d9b638

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.byebug_history
22
Gemfile.*
3+
tmp
4+
doc
35
pkg
46
.idea
57
.ruby-version
8+
.yardoc

cuprite.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
1313
"run your tests on a headless Chrome browser"
1414
s.license = "MIT"
1515
s.require_paths = ["lib"]
16-
s.files = Dir["{lib}/**/*", "LICENSE", "README.md"]
16+
s.files = Dir["lib/**/*", "LICENSE", "README.md"]
1717
s.metadata = {
1818
"homepage_uri" => "https://cuprite.rubycdp.com/",
1919
"bug_tracker_uri" => "https://github.com/rubycdp/cuprite/issues",
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
2525
s.required_ruby_version = ">= 2.6.0"
2626

2727
s.add_runtime_dependency "capybara", "~> 3.0"
28-
s.add_runtime_dependency "ferrum", "~> 0.12.0"
28+
s.add_runtime_dependency "ferrum", "~> 0.13.0"
2929

3030
s.add_development_dependency "byebug", "~> 11.1"
3131
s.add_development_dependency "chunky_png", "~> 1.4"

lib/capybara/cuprite/browser.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def initialize(options = nil)
2323
@page = false
2424
end
2525

26+
def timeout=(value)
27+
super
28+
@page.timeout = value unless @page.nil?
29+
end
30+
2631
def page
2732
raise Ferrum::NoSuchPageError if @page.nil?
2833

lib/capybara/cuprite/page.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Page < Ferrum::Page
1010

1111
extend Forwardable
1212
delegate %i[at_css at_xpath css xpath
13-
current_url current_title body execution_id
13+
current_url current_title body execution_id execution_id!
1414
evaluate evaluate_on evaluate_async execute] => :active_frame
1515

1616
def initialize(*args)

spec/spec_helper.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
require "support/external_browser"
1515

1616
puts ""
17-
command = Ferrum::Browser::Command.build({ window_size: [] }, nil)
17+
command = Ferrum::Browser::Command.build(Ferrum::Browser::Options.new, nil)
1818
puts `'#{command.path}' --version`
1919
puts ""
2020

@@ -69,6 +69,7 @@ module TestSessions
6969
#all with obscured filter should find top nodes outside the viewport when true
7070
#all with obscured filter should only find non-top nodes when true
7171
#fill_in should fill in a color field
72+
#fill_in should handle carriage returns with line feeds in a textarea correctly
7273
#has_field with valid should be false if field is invalid
7374
#find with spatial filters should find an element above another element
7475
#find with spatial filters should find an element below another element
@@ -90,8 +91,8 @@ module TestSessions
9091

9192
if ENV.fetch("CI", nil)
9293
session = @session || TestSessions::Cuprite
93-
session.driver.browser.logger.truncate(0)
94-
session.driver.browser.logger.rewind
94+
session.driver.browser.options.logger.truncate(0)
95+
session.driver.browser.options.logger.rewind
9596
end
9697

9798
example.run
@@ -124,7 +125,7 @@ def save_exception_screenshot(browser, filename, line_number, timestamp)
124125

125126
def save_exception_log(browser, filename, line_number, timestamp)
126127
log_name = "logfile-#{filename}-#{line_number}-#{timestamp}.txt"
127-
File.binwrite("/tmp/cuprite/#{log_name}", browser.logger.string)
128+
File.binwrite("/tmp/cuprite/#{log_name}", browser.options.logger.string)
128129
rescue StandardError => e
129130
puts "#{e.class}: #{e.message}"
130131
end

spec/support/external_browser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Support
55
module ExternalBrowser
66
def with_external_browser
77
url = URI.parse("http://127.0.0.1:32001")
8-
opts = { host: url.host, port: url.port, window_size: [1400, 1400], headless: true }
8+
opts = Ferrum::Browser::Options.new(host: url.host, port: url.port, window_size: [1400, 1400], headless: true)
99
process = Ferrum::Browser::Process.new(opts)
1010

1111
begin

0 commit comments

Comments
 (0)