I'm getting frustrated with this issue.. I have a Test::Unit test.. using Capybara + Poltergeist + PhantomJS.. trying to take a screenshot..

But when I call it..

        page.driver.render "screenshot.png"

It just hangs..

Any ideas? Thanks!

有帮助吗?

解决方案

After all, I had to go with just the Selenium Web driver, and these specific versions, it seems they are out of sync at some point and capybara/its wrapper won't be able to communicate with the driver underneath and therefore Phantom, as a consequence, is not accessible.

This configuration worked for me:

gem 'capybara', '1.1.4'

gem 'selenium-webdriver', '2.27.2'

其他提示

Try being more specific. The following puts it in a temp folder, makes sure that it exists, puts it in there, and then opens it when it's ready.

  dir = "#{Rails.root}/tmp/cache/capybara"
  file = "#{dir}/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.png"
  FileUtils.mkdir_p dir
  page.driver.render file
  wait_until { File.exists?(file) }
  system "open #{file}"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top