My book if finally out! You can pick up a beta copy of the book at the LeanPub site.
A few years ago I set out to master Acceptance Test Driven Development (ATDD, also variously known as Behavior Driven Development or Storytesting). After trying several of the available tools I settled on Cucumber. For Web applications, I also used the most popular Ruby tool for page traversal and verification, Watir.
As I started working with teams to implement this practice, I discovered that the ATDD community was writing more and more new Ruby gems to empower and simplify this kind of testing. I also found that some of the things I personally wanted to simplify were not supported by any existing Ruby gem, so like the crazed developer I am, I set out to build my own. To my surprise, others started using some of the gems I created and began asking a lot of questions about their usage.
This book is my attempt to share as much of my experience using Cucumber and Watir as possible. I will cover many patterns, practices, tools, and (Yes) Ruby gems that make testing applications (particularly but not limited to Web applications) easier including a few of my own. I will also cover the proper way to structure and write your test automation code so that it is less brittle, simpler, better organized, more expressive, and therefore easier to change over the lifecycle of your application. My goal is to help you see and understand the benefits of ATDD and learn how to use Cucumber and Ruby to adopt (and help us refine!) this amazing practice.
This book is full of hands-on programming exercises and I strongly suggest you do them all. Even if you are not testing applications that are like the ones showcased in this book, the knowledge of how to write sound robust tests will transfer to whatever you have to test.
Downloads
The puppy application used in the book can be downloaded from here.

Eagerly waiting for your book ! I hope it will be about a testing framework using Cucumber+RSpec+watir-webdriver. Am I right?
and btw, could you hihg-light the difference between your page object implementation from that of Alister Scott’s (watirmelon.com) ?
Thank You
Feby George
Feby George,
You are right about the topic of my book. It will be focused on those topics as well as other interests for writing robust test suites like test data management, etc.
Alister Scott’s gem is based on a simple module I wrote for a client a couple of years ago and blogged about here. It is a very nice, clean wrapper for making pages. My gem adds a lot more functionality. I believe it addresses many of the problems people have when testing websites.
-Cheezy
Cheezy, So how goes the book? It it getting close?
The book is going very well. Expect a beta release very soon.
I have been given the opportunity to work in corporate environment on an agile software development right out of college as a tester and will start learning about automated tesing soon. I am very much a beginner and have little to no exposure to Ruby and much less programming in general. I will be using RubyMine and Cucumber to develop test scripts so I watned to know if your book will be for an advanced user or a rookie like me?
Thanks,
Rob
The book is targeting the rookie. It assumes you have very little programming background.
really looking forward to this, your website has proved a great source of information. well done!
The book is out now. Let me know what you think about it.
Hi !
I though I was testing not too bad, and after your book, I want to do it better.
So, I am asking myself a lots of details.
- Is it seems acceptable to play with the @browser in a PageObject method ?
- How to go on a particular url in start of a PageObject method ? Actually, I add a cucumber step to make a goto before to use my PageObject.
Fabrice,
1) I think you will not need to play with the @browser in your methods. Everything you should need is available through the PageObject module and supporting classes. If you find some capability that is only available through the @browser instance please let me know so I can add it to the gem.
2) I am not sure how far you are in the book but what you are describing is exactly what the page_url and visit_page combo are designed to do. In you page object you use the page_url class method to define the url for the page and in your step definitions you can use the visit_page(YourPage). This will take you to the page and then you can begin your work.
-Cheezy
Hi Cheezy
I’m new to automated testing, but I’m trying to get my head round Gherkin, BDD and stuff like that. Coming from a PHP background, I have been using Behat and I have thrown a few rather obscure questions at the Behat forum, which led to Marcello telling me I am
‘trying to achieve the “acceptance-testing-centric model” ..’ rather than ‘.. the “system-behaviour-specification-centric model”‘
So, my question is.. should I buy your book? Will it help me understand how to structure acceptance tests and develop a testing framework using Behat, Gherkin, Mink and PHP, or is it purely aimed at the Ruby / Watir / Cucumber world?
I will probably buy it anyway, but if you can tell me it would be useful then I can get the company to pay for it!
Regards
John
John,
This book is definitely targeting the Ruby/Cucumber market. It focuses on several specific gems that I have found helpful when implementing ATDD with teams.
-Cheezy
Hi Cheezy,
I have just started working through the exercises in the book, but as you may already know one of the links required to complete the exercise is not working. This is where you click on the “Adopt Me” button for the chosen puppy and then fill out details. Do you have any idea when this will be back up?
As an alternative can I try downloading the application locally and changing the web links in the ruby scripts?
Thanks
Cantz
Also could you provide instructions on how I can install puppy app locally? (preferably I would like to use the actual puppies web site)
Thanks
Cantz
The chapter on using the database walks you through getting the application running locally.
Thanks
Thanks for the heads up on that. I was not aware that the application was having problems. Heroku upgraded my database (not at my request) on Monday and something must have happened. I’ll look into it today.
That would be great.
Any progress on the test app. It still appears to not be linking from my side?
It is a heroku database update issue. The application is no longer able to insert into the tables. I am still working on it but since I am using a free account there is not much help.
Looks like its up now. Thanks
Hi ,
Hi
I’m trying to run the following command:>testgen project test_puppies
and getting the error below after installing the testgen gem. I have looked around for answers to similar issues on various sites but can’t find anything that seems useful.
Was wondering if you had run into this before and could advise what I can do to solve?
Thanks again
Cantz
C:/Temp/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.1.5/lib/ffi/library.rb:249:in `at
tach_function’: Function ‘uname’ not found in [msvcrt.dll] (FFI::NotFoundError)
from C:/Temp/Ruby193/lib/ruby/gems/1.9.1/gems/sys-uname-0.9.0/lib/unix/s
ys/uname.rb:32:in `’
from C:/Temp/Ruby193/lib/ruby/gems/1.9.1/gems/sys-uname-0.9.0/lib/unix/s
ys/uname.rb:8:in `’
from C:/Temp/Ruby193/lib/ruby/gems/1.9.1/gems/sys-uname-0.9.0/lib/unix/s
ys/uname.rb:6:in `’
from C:/Temp/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:55:in `require’
from C:/Temp/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:55:in `require’
from C:/Temp/Ruby193/lib/ruby/gems/1.9.1/gems/testgen-0.5.1/lib/testgen/
generators/project.rb:2:in `’
from C:/Temp/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:55:in `require’
from C:/Temp/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:55:in `require’
from C:/Temp/Ruby193/lib/ruby/gems/1.9.1/gems/testgen-0.5.1/lib/testgen/
cli.rb:2:in `’
from C:/Temp/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:55:in `require’
from C:/Temp/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
:55:in `require’
from C:/Temp/Ruby193/lib/ruby/gems/1.9.1/gems/testgen-0.5.1/bin/testgen:
3:in `’
from C:/Temp/Ruby193/bin/testgen:23:in `load’
from C:/Temp/Ruby193/bin/testgen:23:in `’
Some extra info that may help.
I have been having trouble executing the commands to install gems as outline in the book. As an example I have tried to run
>gem install rake bundler yard watir-webdriver
ERROR: Could not find a valid gem ‘rake’ (>= 0) in any repository
ERROR: While executing gem … (Gem::RemoteFetcher::FetchError)
Errno::EHOSTUNREACH: A socket operation was attempted to an unreachable host
. – connect(2) (http://rubygems.org/latest_specs.4.8.gz)
The first time I did this on my personal machine it worked. Several weeks later however I tried it on our dev/test machine and it gave the error above. At the time there was a message on the http://rubygems.org/ site saying that the “Dependancy API” was not working 100% and the status of the API was shown as red at http://status.rubygems.org/. I thought that this may have had something to do with it. I then proceeded to download and install each gem manually, including the dependant gems. One of the one’s I missed was the aruba gem. Was wondering if this may be the cause of not being able to run the testgen command above?
So I tried to install the aruba gem but getting following error
C:\Software\Ruby\Gems>gem install aruba
ERROR: While executing gem … (Gem::DependencyError)
Unable to resolve dependencies: childprocess requires ffi (~> 1.0.6)
I already had successfully installed ffi v1.1.5 . I tried to install ffi v1.06 but again got an error and could not proceed with installation
Just tried on another machine and got a similar error. Note the status is all green at http://status.rubygems.org/
>gem install rake bundler yard watir-webdriver
ERROR: Could not find a valid gem ‘rake’ (>= 0) in any repository
ERROR: While executing gem … (Gem::RemoteFetcher::FetchError)
Errno::ETIMEDOUT: A connection attempt failed because the connected party di
d not properly respond after a period of time, or established connection failed
because connected host has failed to respond. – connect(2) (http://rubygems.org/
latest_specs.4.8.gz)
That error typically means that the gem process is unable to make a connection with rubygems.org or one of the other mirrors. Is it possible that the machine you are trying this on is not connected to the internet or is having some networking issues?
Hi
1) I have tried on three different machines within my company LAN , one of which was a virtual machine and they are all displaying the same sort of behaviour. I can access the internet on all of them. I have also tried disconnecting one of the machines from the company LAN and connecting it to my home internet connection and getting similar behaviour.
a) Could it be an issue with rubygems.org web site
b) Is there another way to install them?
2) Do you have any feedback on my initial question regarding the error I was getting running the “testgen create project” command dated October 27, 2012 at 3:47 further up the blog
p.S apologies for all the questions, just eager to get something running!
Thanks
In regards to
1) I think I have solved my network connectivity issues which I think were to do witht he company proxy and firewall settings being in place. I followed the advice here at
http://wiki.openqa.org/display/WTR/Installing+ruby+gems+from+behind+proxy+firewall
In regards to 2) I am still getting this error when I just type in “testgen” at the prompt.
C:\Documents and Settings\Costa Antzoulatos>testgen
C:/Software/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.1.5/lib/ffi/library.rb:2
49:in `attach_function’: Function ‘uname’ not found in [msvcrt.dll] (FFI::NotFou
ndError)
from C:/Software/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/sys-uname-0.9.0/l
ib/unix/sys/uname.rb:32:in `’
from C:/Software/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/sys-uname-0.9.0/l
ib/unix/sys/uname.rb:8:in `’
from C:/Software/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/sys-uname-0.9.0/l
ib/unix/sys/uname.rb:6:in `’
from C:/Software/Ruby/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_r
equire.rb:55:in `require’
from C:/Software/Ruby/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_r
equire.rb:55:in `require’
from C:/Software/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/testgen-0.5.1/lib
/testgen/generators/project.rb:2:in `’
from C:/Software/Ruby/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_r
equire.rb:55:in `require’
from C:/Software/Ruby/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_r
equire.rb:55:in `require’
from C:/Software/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/testgen-0.5.1/lib
/testgen/cli.rb:2:in `’
from C:/Software/Ruby/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_r
equire.rb:55:in `require’
from C:/Software/Ruby/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_r
equire.rb:55:in `require’
from C:/Software/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/testgen-0.5.1/bin
/testgen:3:in `’
from C:/Software/Ruby/Ruby193/bin/testgen:23:in `load’
from C:/Software/Ruby/Ruby193/bin/testgen:23:in `’
I did a check of the testgen gem and discovered that I am no longer using the functionality that caused me to include the sys-uname gem. In response to this discovery I just released a new version of testgen that eliminates that dependency. Please get the latest testgen (version 0.5.2) and then perform a bundle update on your project.
Hey Cheezy, I’m going through this book and I’m loving it! I’ve been using Watir for a few years now. You’re showing me a lot of neat things I can do with the page-object gem.
George,
Really glad you’re enjoying it. Keep the feedback coming. I’m trying to finish the remaining sections by the end of the year so stay tuned.
-Cheezy
Pingback: Using Cucumber to Adopt a Puppy | CheezyWorld
Hi! A concept question. On page 97 you create a module called SideMenuPanel that holds the elements for the side menu and afterwards require and include it on the class.
If the SideMenuPanel is almost all around the site, what about to create a class for it? I know its not a Page but this way you can reference to it as on_page(SideMenuPanel) to perform menu actions and you can continue with on_page(HomePage) for the other interactions. Is there any other problems on that except the Menu is not a Page and is not “elegant” to use a class?
Thank you very much!
There is no reason why this would not work. I do think it does not read as well and might be confusing to some but it will work.
The point I was trying to make in the example in the book was that when we have reusable parts it is nearly always best to make modules that can be included in several pages.
Thanks for reading the book and for your comments.
-Cheezy
Hi
the puppies site seems not working today ?
I’m about to catch a flight and won’t be able to look into it for several hours. Are you getting an error or is it just not coming up at all?
I just tried it and it worked for me. Please try again and let me know if it is still not working for you.
Hello:
I’m trying to follow the Chapter on working with and connecting to Databases and experienced the following issue when setting up the puppy site on my local. In the puppies directory I ran the bundle Install command and received “Could not find addressable-2.3.1 in any of the sources” I checked the rubygems.org site and this version of addressable is marked as yanked. So when I run the rails s command the puppy site does not start. Is there a workaround for this? I’m new to ATDD, and your book has been a tremendous help! Keep up the good work!
Regards
Try deleting the file named Gemfile.lock and then re-run bundle. Another alternative is to run bundle update. Let me know if these work.
I ran the bundle update command as suggested. Success! Thanks for the help!
Regards
I have a problem with “bundle install” in the puppies directory(page 106)
C:\puppies>bundle install
Fetching gem metadata from http://rubygems.org/………
Fetching gem metadata from http://rubygems.org/..
Resolving dependencies…
Could not find addressable-2.3.1 in any of the sources
OS: Windows 7
btw, “test_puppies” project works fine and test_puppies and puppies are in the same diractory
Sorry didn’t noticed the answer above
Gemfile.lock deletion helped
Anna,
No problem. Feel free to post here with any question. I’m happy to help.
-Cheezy
Hello! I purchased your book this week and have found it to be very useful. I have just started the section Cucumbers & Puppies and have run into some problems. I should start by saying that I am behind a corporate firewall and the only way I could get the gems installed was to go to the RubyGems website and download one at a time as I was made aware of the dependencies, and then install from the download folder. My OS is Windows Server 2008 R2 – 64 bit. When I try to run making_cheese.feature, I get the following errors:
C:\Ruby200\bin\ruby.exe -EUTF-8 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:\Ruby200\bin/cucumber C:/RubymineProjects/test_puppies/features/making_cheese.feature –format Teamcity::Cucumber::Formatter –expand –color -r features
Testing started at 1:52 PM …
Using the default profile…
WARNING: cannot load such file — 2.0/gherkin_lexer_en
Couldn’t load 2.0/gherkin_lexer_en
The $LOAD_PATH was:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/bin/../lib
C:/RubyMine 5.0/rb/testing/patch/common
C:/RubyMine 5.0/rb/testing/patch/bdd
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/builder-3.2.0/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/diff-lcs-1.2.1/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-expectations-2.13.0/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/multi_json-1.6.1/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/rubyzip-0.9.9/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/ext/ffi_c
C:/Ruby200/lib/ruby/gems/2.0.0/gems/childprocess-0.3.8/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/websocket-1.0.7/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.30.0/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-webdriver-0.6.2/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/i18n-0.6.4/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/faker-1.1.2/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/yml_reader-0.2/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/data_magic-0.14/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/page_navigation-0.7/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/page-object-0.8.6/lib
C:/Ruby200/lib/ruby/site_ruby/2.0.0
C:/Ruby200/lib/ruby/site_ruby/2.0.0/i386-msvcrt
C:/Ruby200/lib/ruby/site_ruby
C:/Ruby200/lib/ruby/vendor_ruby/2.0.0
C:/Ruby200/lib/ruby/vendor_ruby/2.0.0/i386-msvcrt
C:/Ruby200/lib/ruby/vendor_ruby
C:/Ruby200/lib/ruby/2.0.0
C:/Ruby200/lib/ruby/2.0.0/i386-mingw32. Reverting to Ruby lexer.
No lexer was found for en (cannot load such file — gherkin/lexer/en). Supported languages are listed in gherkin/i18n.json. (Gherkin::I18n::LexerNotFound)
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6/lib/gherkin/i18n.rb:108:in `rescue in lexer’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6/lib/gherkin/i18n.rb:97:in `lexer’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6/lib/gherkin/parser/parser.rb:138:in `transition_table’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6/lib/gherkin/parser/parser.rb:127:in `build_transition_map’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6/lib/gherkin/parser/parser.rb:123:in `transition_map’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6/lib/gherkin/parser/parser.rb:90:in `initialize’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6/lib/gherkin/parser/parser.rb:67:in `new’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6/lib/gherkin/parser/parser.rb:67:in `push_machine’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/gherkin-2.11.6/lib/gherkin/parser/parser.rb:30:in `parse’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib/cucumber/feature_file.rb:37:in `parse’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:28:in `block in load’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:26:in `each’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:26:in `load’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib/cucumber/runtime/features_loader.rb:14:in `features’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:170:in `features’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:46:in `run!’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:43:in `execute!’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:20:in `execute’
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.2.1/bin/cucumber:14:in `’
C:/Ruby200/bin/cucumber:23:in `load’
C:/Ruby200/bin/cucumber:23:in `’
-e:1:in `load’
-e:1:in `’
Any help would be appreciated!
I would suspect that the gems were not installed properly. Please take a look at this page and see if setting the http-proxy value will allow you to get through the firewall. If so, I would suggest installing the gems again. Let me know if this is not an option and we will look at other solutions.
Hi Cheezy
I run into wrong number of arguments error. Please take a look at the output listed below. – Thanks
$ cucumber features/adopt.feature
Using the default profile…
file:/C:/jruby-1.7.2/lib/jruby.jar!/jruby/java/java_package_module_template.rb:11 warning: `eval’ should not be aliased
wrong number of arguments calling `initialize` (0 for 1) (ArgumentError)
c:/jruby-1.7.2/lib/ruby/gems/shared/gems/cucumber-1.2.3/bin/../lib/cucumber/feature_file.rb:31:in `parse’
c:/jruby-1.7.2/lib/ruby/gems/shared/gems/cucumber-1.2.3/bin/../lib/cucumber/runtime/features_loader.rb:28:in `load’
org/jruby/RubyArray.java:1613:in `each’
c:/jruby-1.7.2/lib/ruby/gems/shared/gems/cucumber-1.2.3/bin/../lib/cucumber/runtime/features_loader.rb:26:in `load’
c:/jruby-1.7.2/lib/ruby/gems/shared/gems/cucumber-1.2.3/bin/../lib/cucumber/runtime/features_loader.rb:14:in `features’
c:/jruby-1.7.2/lib/ruby/gems/shared/gems/cucumber-1.2.3/bin/../lib/cucumber/runtime.rb:177:in `features’
c:/jruby-1.7.2/lib/ruby/gems/shared/gems/cucumber-1.2.3/bin/../lib/cucumber/runtime.rb:47:in `run!’
c:/jruby-1.7.2/lib/ruby/gems/shared/g
Cheezy,
Please ignore my post above to do with ‘wrong number of arguments’
That error was gone after removing this line from my steps : include PageObject
Somehow this include syntax was causing the problem. I am all set for now but any explanation about the wrong number of arguments will help. – Thanks.
Sreenivas,
When you included PageObject it added a method named initialize that requires you to pass a browser object. You would only want to include this module in classes that are indeed page objects. That will be explained later in the book.
-Cheezy
i tried runnning chezy on ruby mine but it didn’t ran the tests and showing all tests as failed.
it seems it did not get the step definitions for the written features!
please help
Can you describe to me your directory structure for your project?
I’ve run into this problem with RubyMine as well, and contacting their support they will inform you that you must require ‘minitest’.
However, I solved it by reorganizing my folder structure. I’m not certain what causes this, However your step definitions folder must be inside of the same folder of your features.
e.g. Features are are stored in folder ‘Test’, you must have your ‘step definitions’ folder inside of ‘Test’ as well.
Hope this helps some.
Respectfully,
Rodney U.
You should have all of your features in a directory named features and the step definitions in a directory named step_definitions under that directory. If you use the tool testgen to generate your project structure it will follow this pattern. These are the directories that cucumber is expecting.
Cheezy,
I just want to thank you for writing this blog, your book and building the gems! It has greatly helped me achieve QA goals I was assigned. Please keep the post coming!
Your friend,
Rodney U.
Hi Cheezy,
I am practicing using database chapter. I got below error. how to resolve it?
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.3.1/lib/bundler/resolver.rb:130:in `block in resolve’: Bundler could not find compatible versions for gem “builder”: (Bundler::VersionConflict)
In Gemfile:
activerecord (= 3.2.1) x86-mingw32 depends on
builder (~> 3.0.0) x86-mingw32
cucumber (>= 0) x86-mingw32 depends on
builder (3.2.0)
Give this a try: execute ‘bundle update’ in your project directory.
Thanks. I tried that and it worked. I surprise to see the same answer from you.
Hi, I am not under standing the concept given below. Please explain
myhash = {"emp1" => "sudheer", "emp2" => "cheezy"} myhash.each do |x| puts x endresult:
sudheer
cheezy
Here I understood that, x represent each element in the hash.
In chapter, 5. more puppies
I understood that
unordered_listis a method available in the page_object gem. How we are passing a local variable, (named as a page, here) which is acting as a parent object (like current page) for the div object. Please explain. I am not understanding this block of code.Explanation in the book – “Instead we are passing a block which receives a local variable which is an instance of our page” – actually we are writing a class which is going to represent a page. Where we are creating the instance of our page.
Hope you got my question. Waiting for your response with more excitement.
Sudheer,
This is an excellent question. Thanks for asking.
A block is nothing more than a piece of code that is passed to a method as an argument. At some later point, the method receiving the block decides when it is time to execute that block.
In the case of the
eachmethod above, it takes a single argument which is a block. In theunordered_listmethod above we have the following signature:unordered_list(name, identifier={:index => 0}, &block)This method can be called in one of three ways.
1) You can call it with the name only like this –
unordered_list(:error_list). In this case the second parameter kicks in and it will select the first unordered list if finds when you call one of the generated methods.2) You can call it with the name and identifier like this –
unordered_list(:error_list, :id => 'some_id'). In this case it will use the id to locate the unordered list when you call one of the generated methods.3) You can call it with the name and the block like this –
unordered_list(:error_list) do |page|... end. IN this case it will expect the block to find the unordered list. The reason we can pass the page as a parameter is that the block is not executed until you use one of the generated methods which is after the instance of the page is created.Again, when we call one of the generated methods on the page instance the block is executed and when it is executed it is passed the instance of the page. I hope this all makes sense.
-Cheezy
Hi, Thanks for your immediate responses.
I got a laptop with Windows 8 o/s. installed ruby 1.9.3 and rubymine 4.0.3.
After installing testgen and bundler, using testgen created test_puppies project.
did .bundle install n Bundle update .
Added a first feature as below
Feature: Adopting puppies
Scenario: Adopting one puppy
Given I am on the puppies adoption website
when I ran the scenario got the fallowing error. Tried a lot to resolve but not succeeded. Please help me.
C:\Ruby193\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:\Ruby193\bin/cucumber C:/RubyTraining/test_puppies/features/adopting_puppies.feature –format Teamcity::Cucumber::Formatter –expand –name “Adopting\ one\ puppy” –color -r features
Testing started at 2:34 AM …
wrong number of arguments (1 for 0) (ArgumentError)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/location.rb:22:in `file_colon_line’
C:/Program Files (x86)/JetBrains/RubyMine 4.0.3/rb/testing/patch/bdd/teamcity/cucumber/common.rb:112:in `tc_before_feature’
C:/Program Files (x86)/JetBrains/RubyMine 4.0.3/rb/testing/patch/bdd/teamcity/cucumber/formatter_03103.rb:32:in `before_feature’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/tree_walker.rb:181:in `block in send_to_all’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/tree_walker.rb:179:in `each’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/tree_walker.rb:179:in `send_to_all’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/tree_walker.rb:169:in `broadcast’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/tree_walker.rb:26:in `visit_feature’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/features.rb:28:in `block in accept’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/features.rb:17:in `each’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/features.rb:17:in `each’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/features.rb:27:in `accept’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/tree_walker.rb:21:in `block in visit_features’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/tree_walker.rb:170:in `broadcast’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/ast/tree_walker.rb:20:in `visit_features’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/runtime.rb:48:in `run!’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/lib/cucumber/cli/main.rb:47:in `execute!’
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.3.1/bin/cucumber:13:in `’
C:/Ruby193/bin/cucumber:23:in `load’
C:/Ruby193/bin/cucumber:23:in `’
-e:1:in `load’
-e:1:in `’
Process finished with exit code 1
Empty test suite.
Sudheer,
Please update to the latest version of RubyMine. The error you are experiencing is related to an incompatibility between older versions of RubyMine and a change that was made in Cucumber recently.
-Cheezy
Sir, May I know which version you suggest for the problem. There are 3 versions available after Rubymine 4.0. Thanks
I would grab the latest version which is 5.4.1
When I installed latest version of the rubymine how to make sure that all the gems installed earlier will automatically gets loaded to Rubymine latest version showthat I can see in setttings/rubysdk and gems window.
RubyMine does not actually load the gems. Instead, it points to them. You can select the appropriate version of ruby to use (from the ones you have installed) in the Settings dialog in the section labeled “Ruby SDK and Gems”.
Hi, I am trying to run rubyscripts in Chrome. I am getting the fallowing error for all scrips. Please help me.
Program:
require ‘rubygems’
require ‘watir-webdriver’
browser = Watir::Browser.new :chrome
browser.goto ‘http://www.apple.com’
Error:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/http/common.rb:66:in `create_response’: unexpected response, code=404, content-type=”" (Selenium::WebDriver::Error::WebDriverError)
unknown command: session/url
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/http/default.rb:66:in `request’
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/http/common.rb:40:in `call’
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/bridge.rb:619:in `raw_execute’
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/bridge.rb:597:in `execute’
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/remote/bridge.rb:103:in `get’
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.32.1/lib/selenium/webdriver/common/navigation.rb:14:in `to’
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/browser.rb:77:in `goto’
from C:/rubytraining/learn_ruby/first_script.rb:4:in `’
from -e:1:in `load’
from -e:1:in `’
Process finished with exit code 1
Have you installed the chrome driver?
http://code.google.com/p/selenium/wiki/ChromeDriver
-Cheezy