I am looking for RoR Webrat Selenium Install Recipe

0 views
Skip to first unread message

Audrey A Lee

unread,
Nov 8, 2009, 1:20:04 AM11/8/09
to webrat
Hi there,

I'm trying to follow the ch 22 of the RSpec book.
[ copy is (B11.0 printing, October 28, 2009) ]

I want to use selenium and cucumber.

Ordinary webrat seems to be working well.

Here is info about my RoR:


Sat Nov 07 21:53 /pt/tt11 maco$
Sat Nov 07 21:53 /pt/tt11 maco$
Sat Nov 07 21:53 /pt/tt11 maco$
Sat Nov 07 21:53 /pt/tt11 maco$ script/about
About your application's environment
Ruby version 1.8.7 (i686-darwin9.6.2)
RubyGems version 1.3.5
Rack version 1.0
Rails version 2.3.4
Active Record version 2.3.4
Active Resource version 2.3.4
Action Mailer version 2.3.4
Active Support version 2.3.4
Edge Rails revision b87ab750d1ca166cc2abece3ebf88a8e8d7b7e9f
Application root /pr/tt11
Environment test
Database adapter sqlite3
Database schema version 20091106204750
Sat Nov 07 21:53 /pt/tt11 maco$
Sat Nov 07 21:53 /pt/tt11 maco$
Sat Nov 07 21:53 /pt/tt11 maco$
Sat Nov 07 21:53 /pt/tt11 maco$

I installed these 2 gems and unpacked them in vendor gems:

drwxr-xr-x 7 maco staff 238 Nov 7 21:04 Selenium-1.1.14/
drwxr-xr-x 7 maco staff 238 Nov 7 21:05 selenium-client-1.2.17/

Here are the corresponding config.gem lines in config/environment.rb:

config.gem 'selenium-client', :lib => false, :version => '1.2.17'
config.gem 'Selenium', :lib => false, :version => '1.1.14'

I edited this file:

features/support/env.rb

So it matches this file supplied by the RSpec book:

http://media.pragprog.com/titles/achbd/code/simulated_browser/03/features/support/env.rb

The book-file has a bug which I commented out:

# config.selenium_wait_timeout = 10


When I run cucumber I see this:

Sat Nov 07 21:39 /pt/tt11 maco$
Sat Nov 07 21:39 /pt/tt11 maco$
Sat Nov 07 21:39 /pt/tt11 maco$
Sat Nov 07 21:39 /pt/tt11 maco$
Sat Nov 07 21:39 /pt/tt11 maco$
Sat Nov 07 21:39 /pt/tt11 maco$ script/cucumber features/
welcome_page.feature
Feature: Welcome Page

So that I can feel welcome
As a general user
I want to see a welcome page with 2 columns

Scenario: Show the welcome page to a general user #
features/welcome_page.feature:7
Given the server is up #
features/step_definitions/welcome_page_steps.rb:3
And I am not logged in #
features/step_definitions/welcome_page_steps.rb:7
==> Waiting for Selenium RC server on port 4444... Ready!
==> Waiting for rails application server on port 3001... Ready!
When I go to the homepage #
features/step_definitions/webrat_steps.rb:10
execution expired (Timeout::Error)
/pt/r1/lib/ruby/1.8/timeout.rb:60:in `rbuf_fill'
/pt/r1/lib/ruby/1.8/timeout.rb:62:in `timeout'
/pt/r1/lib/ruby/1.8/timeout.rb:93:in `timeout'
/pt/r1/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
/pt/r1/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
/pt/r1/lib/ruby/1.8/net/protocol.rb:126:in `readline'
/pt/r1/lib/ruby/1.8/net/http.rb:2020:in `read_status_line'
/pt/r1/lib/ruby/1.8/net/http.rb:2009:in `read_new'
/pt/r1/lib/ruby/1.8/net/http.rb:1050:in `request'
/pt/r1/lib/ruby/1.8/net/http.rb:1037:in `request'
/pt/r1/lib/ruby/1.8/net/http.rb:543:in `start'
/pt/r1/lib/ruby/1.8/net/http.rb:1035:in `request'
/pt/r1/lib/ruby/1.8/net/http.rb:845:in `post'
(eval):2:in `/^I go to (.+)$/'
features/welcome_page.feature:11:in `When I go to the homepage'
Then I should see a page with 2 columns #
features/step_definitions/welcome_page_steps.rb:15
And the LHS column should be relatively narrow #
features/step_definitions/welcome_page_steps.rb:20
And the RHS column should be much more prominent #
features/step_definitions/welcome_page_steps.rb:25
And the LHS column should have the links: login, register #
features/step_definitions/welcome_page_steps.rb:30
And the RHS should only contain the word Welcome #
features/step_definitions/welcome_page_steps.rb:36

1 scenario (1 failed)
8 steps (1 failed, 5 skipped, 2 passed)
5m4.081s
21:45:05.220 ERROR - Exception running '0 'command on session null
java.lang.NullPointerException: sessionId should not be null; has this
session been started yet?
at org.openqa.selenium.server.FrameGroupCommandQueueSet.getQueueSet
(FrameGroupCommandQueueSet.java:212)
at org.openqa.selenium.server.commands.SeleniumCoreCommand.execute
(SeleniumCoreCommand.java:34)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand
(SeleniumDriverResourceHandler.java:516)
at
org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest
(SeleniumDriverResourceHandler.java:368)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle
(SeleniumDriverResourceHandler.java:129)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.http.HttpServer.service(HttpServer.java:909)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:
982)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
at org.mortbay.http.SocketListener.handleConnection
(SocketListener.java:244)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Sat Nov 07 21:45 /pt/tt11 maco$
Sat Nov 07 21:45 /pt/tt11 maco$
Sat Nov 07 21:45 /pt/tt11 maco$
Sat Nov 07 21:45 /pt/tt11 maco$
Sat Nov 07 21:45 /pt/tt11 maco$

I inspected the process listing:


Sat Nov 07 21:39 /pt/tt11 maco$
Sat Nov 07 21:39 /pt/tt11 maco$
Sat Nov 07 21:39 /pt/tt11 maco$
Sat Nov 07 21:39 /pt/tt11 maco$
Sat Nov 07 21:39 /pt/tt11 maco$
Sat Nov 07 21:39 /pt/tt11 maco$ psorg java

maco 1351 0.0 1.0 343076 21312 s000 S 9:40PM
0:00.63 /usr/bin/java -jar /Users/maco/pt/customers3/thubten/tt11/
vendor/gems/webrat-0.4.4/vendor/selenium-server.jar -port 4444 -
timeout 0
maco 1381 0.0 0.0 599820 464 p0 S+ 9:46PM 0:00.00
grep -i java
Sat Nov 07 21:46 /pt/tt11 maco$
Sat Nov 07 21:46 /pt/tt11 maco$
Sat Nov 07 21:46 /pt/tt11 maco$
Sat Nov 07 21:46 /pt/tt11 maco$
Sat Nov 07 21:46 /pt/tt11 maco$

It looks like Selenium-RC is getting started.

But I sense that Selenium-RC is broken or my call to script/cucumber
cannot connect to Selenium-RC.

Is there a recipe for getting cucumber and selenium to work together.

It worries me that the RSpec book is not specific about gem versions.

I'd like to see a recipe which has a very specific list of ingredients
I need in order to operate cucumber with Selenium.

Can anyone offer a clue?

Thanks.

Scott Smith

unread,
Nov 10, 2009, 7:27:35 PM11/10/09
to web...@googlegroups.com
Hi Audrey,

Shot in the dark: is Webrat set up to access port 3001 while your Rails app is actually on port 3000?

That might explain the timeout.

Scott
--
Scott Smith

With privilege comes responsibility,
with responsibility comes accountability,
with accountability comes honesty,
with honesty comes faithfulness.
Reply all
Reply to author
Forward
0 new messages