最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to display JS errors in Capybara + ChromeDriver? - Stack Overflow

programmeradmin3浏览0评论

I have an integration test setup that uses RSpec + Capybara. We recently switched from PhantomJS to headless Chromedriver and I miss that javascript errors are not displayed anymore.

Is there a convenient way of configuring Chromedriver so that javascript errors show up in the log output of capybara tests?

The ways of accessing the javascript errors I found (see below) all are a bit cumbersome or not really what I was looking for.

  • setting an explicit log output path as described in this answer
  • accessing the (kind of cut back) error log through the driver interface as described in this gist

I have an integration test setup that uses RSpec + Capybara. We recently switched from PhantomJS to headless Chromedriver and I miss that javascript errors are not displayed anymore.

Is there a convenient way of configuring Chromedriver so that javascript errors show up in the log output of capybara tests?

The ways of accessing the javascript errors I found (see below) all are a bit cumbersome or not really what I was looking for.

  • setting an explicit log output path as described in this answer
  • accessing the (kind of cut back) error log through the driver interface as described in this gist
Share Improve this question edited Feb 25, 2020 at 10:12 juffel asked Mar 14, 2018 at 16:12 juffeljuffel 1,11516 silver badges21 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 12

With

RSpec.configure do |config|
  config.after(type: :feature) do
    STDERR.puts page.driver.browser.manage.logs.get(:browser)
  end
end

one can print out the logs after each example, that is a feature spec with RSpec. Should be similar in other test frameworks. This does not fail the example however.

Assuming your second method is referring to the ments in that gist rather than the method that requires installing an extension, then no there isn't. Selenium is basing its functionality/feature support off the WebDriver spec - https://w3c.github.io/webdriver/webdriver-spec.html - which doesn't specify anything about reporting JS errors back to the automation client.

Note - there are configuration options for the Chrome logs which may change the verbosity and get rid of the "kind of cut back" issue - see Capture browser console logs with capybara

发布评论

评论列表(0)

  1. 暂无评论