[rspec-users] [cucumber] webrat+selenium integration problem: record n

Mateusz Juraszek lists at ruby-forum.com
Sun Apr 5 15:41:18 EDT 2009

Balint Erdi wrote:
> Ben Mabey wrote:
>> Couple things I'd like to point out.  In your enhanced.rb you don't need
>> to do the Before hook yourself.  You can just require
>> 'database_cleaner/cucumber'.  I've updated your gist to use that.
>> In your plain.rb it seems like you are trying to truncate your database
>> just once upon startup.  If that is the case then the recommended way is
>> to use the clean_with method like so:
>> DatabaseCleaner.clean_with :truncation
>> Again, I have updated the gist to reflect this.
>> -Ben
> Hey Ben, thanks a lot.
> The problem I am experiencing now is that information stored in the 
> session does not seem to be retained between steps (again, only in the 
> case of selenium sessions, plain sesssion work fine). So the login 
> function works fine now but when I go to another page afterwards it 
> throws a big error because the action tries to render something based on 
> the current user.
> Is the session store I am using relevant? I used the default 
> cookie-based storage and then tried to change to the active-record based 
> one to no avail. My config is at http://gist.github.com/83635
> Thank you,
> Balint

hi Ben

I am newbie with cucumber and bdd. I was wondering if you can take a 
look on my problems.
I have similar problem like Balint. I test my own and clearance features 
with selenium and webrat. I don't have to say that with werbrat 
everything is perfect. When I run features with selenium I get error 
nil.session what is connected with code from clearance features ie:
Then /^I should not be signed in$/ do
  assert_nil request.session[:user_id]
in clearance_step file

It seems like selenium has problem with access to "request" object
That makes my test fail all the time.

Another problem I met is with waiting for response after "press button" 
All the time I get response with code before button pressed
It's connected with selenium_session.rb code and require me to change a 
    def click_button(button_text_or_regexp = nil, options = {})
      if button_text_or_regexp.is_a?(Hash) && options == {}
        pattern, options = nil, button_text_or_regexp
      elsif button_text_or_regexp
        pattern = adjust_if_regexp(button_text_or_regexp)
      pattern ||= '*'
      locator = "button=#{pattern}"

      selenium.wait_for_element locator, :timeout_in_seconds => 5
      selenium.click locator
      selenium.wait_for_page_to_load(5) ## add this line to get correct 
I don't know why I have to change it
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list