So i am using Cabybara to take screenshots like this
Capybara.register_driver(:poltergeist) { |app| Capybara::Poltergeist::Driver.new(app, js_errors: false) }
Capybara.default_driver = :poltergeist
session = Capybara.current_session
session.visit url
session.save_screenshot('image.png',full: true)
But now i encountered a page where i have to login, how can i login and take screen shot of this web page using Capybara ?
You need to fill out the login fields, click whatever button submits the login info, then wait until the login completes and then take your screenshot. Something like
session.visit url
session.fill_in 'Email', with: 'user@example.com'
session.fill_in 'Password', with: 'password'
session.click_button 'Sign in'
expect(session).to have_content 'You are now logged in!'
session.save_screenshot('image.png',full: true)
although the specific details are going to vary based on the page/fields you're trying to log into