0

I want to be able to login and then visit my profile page to scrape some information. The login works perfectly but when i visit the profile page it doesn't display it correctly and im asked to login again. Like as if a cookie wasn't set or session wasn't created. How can I do this?

I'll also mention, the site relies heavily on frames and Javascript, it doesn't work with mechanize for example.

require 'capybara-webkit'
require 'capybara/dsl'
require 'nokogiri'

include Capybara::DSL
Capybara.current_driver = :webkit_debug
Capybara.app_host = "https://site.com"
login = '/start.asp'
target = '/profile'

visit(login)

fill_in('user', :with => 'user)
fill_in('pass', :with => 'pass')
my_link = find(:xpath, '//*[@id="loginform"]/div/div[2]')
my_link.click

visit(target)
John Wessen
  • 5
  • 1
  • 3

1 Answers1

0

I'd try something like this :

require 'capybara'
session = Capybara::Session.new(:selenium)
session.visit("https://site.com/start.asp")
session.fill_in('user', :with => 'user')
session.fill_in('pass', :with => 'pass')
session.click_link 'Login'
...
session.visit("https://site.com/profile")

capybara github repo - Using the sessions manually

cheatsheat

ajt
  • 553
  • 8
  • 25