Reputation: 51
I'm trying to move away from Poltergeist/PhantomJS through the use of Apparition.
Configuring the driver is working as expected, with the exception of output of Chrome logs.
This is my driver configuration:
Capybara.register_driver :apparition do |app|
options = {
debug: false,
headless: true,
browser_logger: STDOUT,
timeout: 3,
ignore_https_errors: true,
screen_size: [1920, 1080],
skip_image_loading: false,
js_errors: false,
headers: {
"User-Agent" => "Apparition"
}
}
Capybara::Apparition::Driver.new(app, options)
end
I expected to see Chrome's console output mixed in with Capybara's, but absolutely nothing is being produced.
Is my syntax incorrect?
Thanks, Shaun
Upvotes: 0
Views: 883
Reputation: 16294
If I do e.g. console.log("foo")
in JavaScript, our Capybara + Apparition tests will output that during the run. So, yes, Capybara + Apparition normally has that behaviour.
Try removing all those options and see how you do.
Here's a self-contained example of console.log
outputting stuff. Save it as example.rb
and run it with ruby example.rb
. (Example code mostly from https://github.com/teamcapybara/capybara/issues/2256#issuecomment-542238546.)
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "capybara"
gem "puma"
gem "apparition"
end
require "capybara/apparition"
require "capybara/dsl"
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
Capybara.register_driver :apparition do |app|
Capybara::Apparition::Driver.new(app,
)
end
sess = Capybara::Session.new(:apparition, app)
sess.visit("/")
__END__
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello!</title>
<script>
console.log("hi");
</script>
</head>
<body>
<p>Hello world.</p>
</body>
</html>
This example will still output the log even if I add all the options you use, though, so there may be something else going on.
Upvotes: 0