Sadness - I can't even get the first script to work!

271 views
Skip to first unread message

Lisa Crispin

unread,
Feb 26, 2015, 7:50:25 PM2/26/15
to cucumber-...@googlegroups.com
I wrote and maintained Ruby / Watir scripts from 2006 - 2011, and wrote WebDriver scripts in  Robot Framework using Page Object for a few months in 2012, so I thought at least the first few scripts in Cucumber and Cheese would be a breeze! Unfortunately I failed at the very first one.

When I try to run it in RubyMine, I get an error:
/Users/pivotal/.rvm/rubies/ruby-2.1.1/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/pivotal/workspace/learn_watir/first_script.rb
/Users/pivotal/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- watir-webdriver (LoadError)
    from /Users/pivotal/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/pivotal/workspace/learn_watir/first_script.rb:2:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

I've installed the gem, pls see screenshot, so I don't know why it can't find it.

When I run from the command line, it does pop up a Firefox window, then just hangs. When I kill it with ctrl c, I get:
ruby first_script.rb
^C/Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/socket_poller.rb:95:in `sleep': Interrupt
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/socket_poller.rb:95:in `wait'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/socket_poller.rb:88:in `with_timeout'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/socket_poller.rb:23:in `connected?'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/firefox/launcher.rb:77:in `connect_until_stable'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/firefox/launcher.rb:37:in `block in launch'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/firefox/bridge.rb:24:in `initialize'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/driver.rb:31:in `new'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/driver.rb:31:in `for'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver.rb:67:in `for'
    from /Users/pivotal/.rvm/gems/ruby-2.1.5@tracker/gems/watir-webdriver-0.6.11/lib/watir-webdriver/browser.rb:46:in `initialize'
    from first_script.rb:3:in `new'
    from first_script.rb:3:in `<main>'

Help please! I feel like a complete ninny!
Screen Shot 2015-02-26 at 5.44.08 PM.png
Screen Shot 2015-02-26 at 4.13.02 PM.png
Screen Shot 2015-02-26 at 5.42.24 PM.png
Screen Shot 2015-02-26 at 4.12.53 PM.png

Rob Park

unread,
Feb 26, 2015, 10:25:39 PM2/26/15
to Lisa Crispin, cucumber-...@googlegroups.com
On Thu, Feb 26, 2015 at 7:50 PM Lisa Crispin <lisa.c...@gmail.com> wrote:
I wrote and maintained Ruby / Watir scripts from 2006 - 2011, and wrote WebDriver scripts in  Robot Framework using Page Object for a few months in 2012, so I thought at least the first few scripts in Cucumber and Cheese would be a breeze! Unfortunately I failed at the very first one.

When I try to run it in RubyMine, I get an error:
/Users/pivotal/.rvm/rubies/ruby-2.1.1/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/pivotal/workspace/learn_watir/first_script.rb
/Users/pivotal/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- watir-webdriver (LoadError)
    from /Users/pivotal/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/pivotal/workspace/learn_watir/first_script.rb:2:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

I've installed the gem, pls see screenshot, so I don't know why it can't find it.

What does your 'run configuration' in RubyMine look like? 
Assuming latest RubyMine...
I find setting the working dir to the project root... and running from a tag consistently works the best. But it also looks like RM is running from 2.1.1, but your cmd line is 2.1.5. You can set your Ruby in the run config and/or for the project in RM as well.

@rob

Željko Filipin

unread,
Feb 27, 2015, 5:07:08 AM2/27/15
to Lisa Crispin, cucumber-...@googlegroups.com
Does the script run fine from terminal?

Željko

Lisa Crispin

unread,
Feb 27, 2015, 7:58:29 AM2/27/15
to Željko Filipin, cucumber-...@googlegroups.com
No, I included the output from the command line in the screenshots.

I did change the RubyMine preferences to Ruby 2.1.5 (no idea how our own code works there since it also requires 2.1.5) and did a bundle install, and got instead "Could not locate Gemfile" when I ran it.

Given this book is supposed to be for newbies, I'm either a total idiot in spite of my experience using Ruby, Watir, Webdriver and RubyMine, or there are instructions missing, or I'm blind. It's super-frustrating.
--
Lisa Crispin
Co-author with Janet Gregory, More Agile Testing: Learning Journeys for the Whole Team, and Agile Testing: A Practical Guide for Testers and Agile Teams
http://lisacrispin.com
http://agiletester.ca
@lisacrispin on Twitter

Lisa Crispin

unread,
Feb 27, 2015, 7:59:37 AM2/27/15
to Rob Park, cucumber-...@googlegroups.com
I do have a fairly up to date RubyMine - I'll check when I get back on that macbook.

I woulda thought the working dir is already the project root but I'll check that. And I don't know what you mean by "running from a tag".

Thanks, everyone, for the help!

Rob Park

unread,
Feb 27, 2015, 11:32:43 AM2/27/15
to Lisa Crispin, cucumber-...@googlegroups.com
On Fri, Feb 27, 2015 at 7:59 AM Lisa Crispin <lisa.c...@gmail.com> wrote:
I do have a fairly up to date RubyMine - I'll check when I get back on that macbook.

I woulda thought the working dir is already the project root but I'll check that. And I don't know what you mean by "running from a tag".

Yeah, it's not obvious in RubyMine what the root is and depends where you run it from.

With Cucumber, you can "tag" a scenario...
@wip
Scenario: my behavior
...

And then run from the cmd line with --tags @wip
Or a multitude of other ways :(

So I can appreciate that the initial ramp up is tough ... just to get started ... a lot of the time. 

Zeljko's suggestion is a good one to first ensure it runs from the cmd line.
Now looking at your screenshot more closely, from the cmd line you should be able to just invoke 'cucumber'... or with tags: cucumber --tags @wip. You will need to first 'gem install cucumber' if you haven't already.

@rob

Lisa Crispin

unread,
Feb 27, 2015, 12:21:10 PM2/27/15
to Rob Park, cucumber-and-cheese
Did I miss some instruction in the book? I don't recall that it says 'gem install cucumber'.

Since my main goal is to brush up my Ruby skills, I'm giving up on this and I'll pursue some other avenue such as Ruby Koans.

Thanks!

Paul Carvalho

unread,
Apr 9, 2015, 8:39:29 PM4/9/15
to cucumber-...@googlegroups.com
Hi Lisa, I just joined this group today and saw your message. Did you get this working?

You ask a few different questions so if you are still interested, here are some thoughts..

The first question below: when do you install cucumber in the book?

The cucumber gem is installed at the start of Chapter 4 when you install testgen. Up until that point you don't need cucumber. The exercises in chapter 3 are all ruby and watir/webdriver. Testgen is useful to create cucumber project spaces, so it includes everything you need to get started.

The error message "Could not locate Gemfile" is an easy one to correct. Create a file with that name (and no extension) in the root directory for your project. I'm not sure why it's asking you for that if you don't have a cucumber project.

As for your first issue, when you installed the watir-webdriver gem, it looks like you were using ruby 2.1.5. The error message says that it can't find the gem in ruby 2.1.1. The gems are installed for specific versions of ruby, so if you switch the version you need to reinstall the gems.

You can check the installed gems with the command "gem list" at the command prompt and switching between the different ruby versions. In RubyMine, you can also check in the Settings page under "Ruby SDK and Gems" >> click a different ruby version and check the gem list on the right to check if watir-webdriver is installed. If it's not, RubyMine will likely ask you to install the gem and that might lead it to wondering where the Gemfile is.

Please let me know if this helps. Hope you gave the book another chance.

Cheers! Paul.
Reply all
Reply to author
Forward
0 new messages