mattheworiordan / capybara-screenshot

Automatically save screen shots when a Capybara scenario fails
MIT License
1.02k stars 168 forks source link

WARN: Screenshot could not be saved. `page.current_path` is empty #243

Closed brandoncc closed 5 years ago

brandoncc commented 6 years ago

Using:

capybara-screenshot 1.0.21 Rails 4.2.0 capybara 2.14.3

I get:

WARN: Screenshot could not be saved. `page.current_path` is empty

on CircleCI, but it seems to work fine locally. Is this a known problem?

ekinciq commented 6 years ago

Hi I have same issue.

Using: capybara-screenshot 1.0.22 Cucumber 3.1.2 capybara 3.11.1

I get error in my local as well

mattheworiordan commented 5 years ago

@brandoncc what driver where you using?

@ekinciq did you ever work around the issue?

Can someone provide a stack trace at least and some more description of what the test is doing and what driver is being used etc. so it can be reproduced. If you have a sample project that can reproduce this, then it will easy to roll out a fix.

ekinciq commented 5 years ago

@mattheworiordan i had a work around. I changed the order in my hook file so it stopped calling reset_browsers before taking thw screenshot.

brandoncc commented 5 years ago

I don't remember anymore but I got it working. I also don't remember how I did that :-/

szTheory commented 5 years ago

I had to change both capybara-screenshot and rspec-rails to get it working in Rails 6. See:

rogerkk commented 4 years ago

@mattheworiordan FWIW, I'm seeing this issue while using headless_chrome.

I'm opening a page, filling in some form fields and clicking a button, at which point the spec fails and this message appears.

csibug commented 4 years ago

@mattheworiordan FWIW, I'm seeing this issue while using headless_chrome.

I'm opening a page, filling in some form fields and clicking a button, at which point the spec fails and this message appears.

Yes, i'm getting "WARN: Screenshot could not be saved. page.current_path is empty." with headless_chrome too. i can create screenshots manually with screenshot_and_save_page.

GalenkoEugene commented 4 years ago

@mattheworiordan FWIW, I'm seeing this issue while using headless_chrome.

I'm opening a page, filling in some form fields and clicking a button, at which point the spec fails and this message appears.

I also have a similar problem while using headless_chrome, the reason was:

config.after(:each, js: true) do
  Capybara.reset!
end

I have replaced it with:

config.retry_callback = proc do |ex|
  Capybara.reset! if ex.metadata[:js]
end

And now everything works as expected :tada:

brandoncc commented 4 years ago

Thanks for sharing a working solution, @GalenkoEugene!

MunimIftikhar commented 3 years ago

@GalenkoEugene Can you please specify the file name where you made these changes?

GalenkoEugene commented 3 years ago

@GalenkoEugene Can you please specify the file name where you made these changes?

../spec/support/capybara.rb

inside configuration block...

RSpec.configure do |config|
  config.retry_callback = proc do |ex|
    Capybara.reset! if ex.metadata[:js]
  end
end

Generally, you could put it into any config file. Don't forget to require it in spec_helper.rb

MunimIftikhar commented 3 years ago

I'm running the test using bundle exec rspec which gives me the error of: WARN: Screenshot could not be saved.page.current_pathis empty. also this: Failure/Error: expect(page).to have_selector(".name", text: "Take Notes"). I used all above-mentioned solutions, but nothing worked. Can anyone help me with this?

marcdonovan commented 3 years ago

I have this issue in the following public repo git clone git@bitbucket.org:marcdonovan/se.git

$ rails --version Rails 6.1.4.1

git checkout screenshot to see the problem.

Should be able to reproduce from this.

dacook commented 2 years ago

Closed but continued here: #277