0

So I'm brand new to Watir / Cucumber and I'm doing a tutorial that involves writing a script to go to a fake puppy adoption website and then adopt a puppy. When I wrote this just as a Watir script it worked fine, but now I'm trying to run it as a Cucumber scenario and I'm having problems.

It's navigating correctly through the site, but it comes to a page where it has to fill in multiple text fields. For some reason it always fills out the first text field and then just sits there until it times out. I have no idea why this is happening - I tried literally copy/pasting the code that the tutorial says should work and it's still happening.

Here's the cucumber feature:

Feature: Adopting Puppies
  As a pupppy lover
  I want to adopt puppies
  So they can chew my furniture

  Scenario: Adopting one puppy
    Given I am on the puppy adoption site
    When I click the View Details button
    And I click the Adopt Me button
    And I click the Complete the Adoption button
    And I enter "Name" in the name field
    And I enter "123 Main St." in the address field
    And I enter "name@foo.com" in the email field
    And I select "Credit Card" from the pay with dropdown
    And I click the Place Order button
    Then I should see "Thank you for adopting a puppy!"

It's entering "Name" in the correct field, but never enters the address.

Here are the step definitions:

Given /^I am on the puppy adoption site$/ do
  @browser.goto "http://puppies.herokuapp.com"
end
When /^I click the View Details button$/ do
  @browser.button(:value => "View Details").click
end
When /^I click the Adopt Me button$/ do
  @browser.button(:value => "Adopt Me!").click
end
When /^I click the Complete the Adoption button$/ do
  @browser.button(:value => "Complete the Adoption").click
end
When /^I enter "([^\"]*)" in the name field$/ do |name|
  @browser.text_field(:id => "order_name").set(name)
end
When /^I enter "([^\"]*)" in the address field$/ do |address|
  @browser.text_field(:id => "order_address").set(address)
end
When /^I enter "([^\"]*)" in the email field$/ do |email|
  @browser.text_field(:id => "order_email").set(email)
end
When /^I select "([^\"]*)" from the pay with dropdown$/ do |pay_type|
  @browser.select_list(:id => "order_pay_type").select(pay_type)
end
When /^I click the Place Order button$/ do
  @browser.button(:value => "Place Order").click
end
Then /^I should see "([^\"]*)"$/ do |expected|
  expect(@browser.text).to include expected
end

Not sure what other details to give. I'm using Firefox as the browser. Anyone have any idea why this isn't working?

Race Morel
  • 11
  • 4
  • Which step definition is failing? And can you provide the site-under-test (or representative HTML)? – orde Aug 14 '17 at 00:11
  • The "order address" is the one that's failing. Or rather, it isn't failing it's just not executing, so the whole thing times out. It enters the "name" perfectly fine, but then just doesn't enter the address. The site is http://puppies.herokuapp.com – Race Morel Aug 14 '17 at 01:34
  • The name element is an `` tag, but the address element is a ` – orde Aug 14 '17 at 03:46
  • That worked! Thank you so much! – Race Morel Aug 14 '17 at 05:59

0 Answers0