Links to My Posts

Labels

Blogumulus by Roy Tanck and Amanda Fazani
free counters

How many in online

Nokia 7705 Twist


The Nokia 7705 Twist is a cute swivel QWERTY phone. It comes with 3-megapixel camera, 2.4-inch, 262K TFT QVGA screen, EV-DO Rev. 0, 2.5 mm headset jack, Bluetooth, HTML browser, built-in mirror, “Post to Blogs” feature and Compatible with services including VZ NavigatorSM, V CAST Music with Rhapsody, V CAST Video, Visual Voice Mail, Mobile Broadband Connect and Corporate Email. It is available through Verizon Wireless at $99.99 after a $50 mail-in rebate with a new two-year customer agreement.



Cucumber and Ruby on Rails (Part 7) My learning materials

Now lets see a scenario to go through the links and how the cucumber deals with that scenario.
Before write the scenario lets look at the scree shots and what could be the scenario.

1 Step:- I am on the “List of products” page and I can see
Titled = Ruby on Rails
Description = Model View Architecture
Image url = ror.jpg
Price = 22


2 Step:- Now I click on “New Product” link.


3 Step:- Now click on “Back” link again. Then I am again on “List of Products”.


4 Step:- Now click on “Show” link and then I can see



5 Step: like wise we can navigate through the links

Now lets see how this scenario can be written. Before that look at these step definitions. You can find them in webrat_steps.rb file.

When /^I press "([^\"]*)"$/ do |button|
click_button(button)
end

This can be used for when we click on button

When /^I follow "([^\"]*)"$/ do |link|
click_link(link)
end

When /^I follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|

click_link_within(parent, link)

end

These two can be used when we navigate through the links.
Now lets see the scenario.

Scenario: Go Through Links
Given I have products titled Ruby on Rails, description Model View Architecture, Image url ror.jpg, Price 22
When I go to the list of Products
Then I should see "Ruby on Rails"
And I should see "Model View Architecture"
And I should see "ror.jpg"
And I should see "22"
When I follow "New Product"
And I follow "Back"
And I am on the list of Products
Then I should see "Ruby on Rails"
And I should see "Model View Architecture"
And I should see "ror.jpg"
And I should see "22"
When I follow "Show"
Then I should see "Ruby on Rails"
And I should see "Model View Architecture"
And I should see "ror.jpg"
And I should see "22"
When I follow "Back"
And I am on the list of Products
Then I should see "Ruby on Rails"
And I should see "Model View Architecture"
And I should see "ror.jpg"
And I should see "22"
When I follow "Edit"
And I follow "Back"
And I am on the list of Products
Then I should see "Java"
And I should see "Platform Independent"
And I should see "java.jpg"
And I should see "20"

save this scenario as go_through_links.feature and run the cucumber features/go_through_links.feature

Then you can see the following screen shot.


Why this scenario failed. Look at these steps.

When I follow "Edit"
And I follow "Back"
And I am on the list of Products
Then I should see "Java"
And I should see "Platform Independent"
And I should see "java.jpg"
And I should see "20"

These steps are wrong. They should be as follows.

When I follow "Edit"
And I follow "Back"
And I am on the list of Products
Then I should see "Ruby on Rails"
And I should see "Model View Architecture"
And I should see "ror.jpg"
And I should see "22"

Edit the feature file and run again cucumber features/go_through_links.feature. Now you can get the all the steps are passed massage.


This is how the cucumber work with the navigation scenario.