We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
You can continue the conversation there. Go to discussion →
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to invoke Ferrum::Browser.new inside a Rails controller and access an action that requires authentication.
Ferrum::Browser.new
However it naturally brings me to/renders the sign_in page:
I know that I could do something like this to authenticate the user
browser.go_to "http://localhost:3000/users/sign_in" browser.at_css("#user_email").focus.type(current_user.email) browser.at_css("#user_password").focus.type(current_user.password) browser.at_css("input[type='submit']").click browser.go_to url_for(report_url(@report))
However is there a legit way to set the user in the browser?
I was thinking something like this, but it does not seem to work:
cookie = request.cookies["_myapp_session"] browser.cookies.set(name: '_myapp_session', value: cookie, domain: 'localhost')
full code:
def show respond_to do |format| format.html format.pdf do cookie = request.cookies["_myapp_session"] filename = "newfile.pdf" tmp = Tempfile.new(filename) browser = Ferrum::Browser.new browser.cookies.set(name: '_myapp_session', value: cookie, domain: 'localhost') browser.go_to url_for(report_url(@report)) sleep(1) pdf = browser.pdf(path: tmp.path, format: "A4".to_sym, scale: 1, landscape: false) browser.quit pdf_data = File.read(tmp.path) send_data(pdf_data, type: "application/pdf", disposition: "inline", filename: filename) end end end
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am trying to invoke
Ferrum::Browser.new
inside a Rails controller and access an action that requires authentication.However it naturally brings me to/renders the sign_in page:
I know that I could do something like this to authenticate the user
However is there a legit way to set the user in the browser?
I was thinking something like this, but it does not seem to work:
full code:
The text was updated successfully, but these errors were encountered: