From 973cc4172b5452af98e67aea06f107a6ff645a73 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Thu, 21 Aug 2014 16:51:48 -0400 Subject: [PATCH] Fix up all tests --- .gitignore | 1 + config/cucumber.yml | 2 +- features/main.feature | 11 ++- features/step_definitions/common_steps.rb | 94 +++++++++++++++++++--- features/step_definitions/example_steps.rb | 29 ------- features/step_definitions/myapp_steps.rb | 66 --------------- features/support/hooks.rb | 9 +++ 7 files changed, 100 insertions(+), 112 deletions(-) delete mode 100644 features/step_definitions/example_steps.rb delete mode 100644 features/step_definitions/myapp_steps.rb diff --git a/.gitignore b/.gitignore index 99cfa87..aa9149a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.bundle /vendor +/results diff --git a/config/cucumber.yml b/config/cucumber.yml index 791409f..6f94b0a 100644 --- a/config/cucumber.yml +++ b/config/cucumber.yml @@ -1 +1 @@ -default: features --tag ~@wip -tag ~@manual +default: features --tag ~@wip --tag ~@manual diff --git a/features/main.feature b/features/main.feature index 08220f0..968e8ed 100644 --- a/features/main.feature +++ b/features/main.feature @@ -1,22 +1,25 @@ Feature: Main tests + In order to make sure that the web page is working + As a normal user + I want to check out the home page in a variety of aspect ratios @smoke @regression @desktop Scenario: Visit the home page - Given I am on the moduscreate home page + Given I am on the desktop home page Then I must see the page title "Modus Create | HTML5 Application Development & Training" Given I click the "Services" span Then I must see the page title "Services | Modus Create" @regression @mobile Scenario: Visit the home page on a mobile device - Given I am on the moduscreate home page + Given I am on the desktop home page Then I must see the page title "Modus Create | HTML5 Application Development & Training" Given I click the "icon-reorder" icon - And I wait for the menu to b displayed + And I wait for the menu to be displayed @wip @tablet Scenario: Visit the home page on a tablet - Given I am on the moduscreate home page + Given I am on the desktop home page Then I must see the page title "Modus Create | HTML5 Application Development & Training" Given I click the "Blog" span Then I must see the page title "Blog | Modus Create" diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb index 042233a..8fcf22b 100644 --- a/features/step_definitions/common_steps.rb +++ b/features/step_definitions/common_steps.rb @@ -3,10 +3,6 @@ puts "URL = #{@browser.url}" #This step links up with the "path_to" method found in support/paths.rb end -Then(/^I must see the page title "(.*?)"$/) do |title| - assert_equal(@browser.title, title) -end - Given(/^I fill in the text field "(.*?)" with "(.*?)"$/) do |text_field_name, text| @browser.text_field(:name => text_field_name).set text end @@ -19,10 +15,6 @@ @browser.button(:text => button_text).click end -Given(/^I click the "(.*?)" span$/) do |span_text| - @browser.span(:text => span_text).click -end - Given(/^I wait for the "(.*?)" text to be displayed$/) do |text| Watir::Wait.until { @browser.text.include? text } end @@ -31,10 +23,6 @@ assert_equal(true,@browser.text.include?(text)) end -Given(/^I click the "(.*?)" link$/) do |link_text| - @browser.link(:text => link_text).click -end - Given(/^I wait for the "(.*?)" message\-box to be displayed$/) do |arg1| @browser.div(:class => "popover-content").wait_until_present end @@ -51,3 +39,85 @@ end end + +Then(/^I must see the page title "(.*?)"$/) do |title| + assert_equal(title,@browser.title) +end + +###### Links +Given(/^I click the "(.*?)" link$/) do |ele| + case + when @browser.link(:id, ele).exists? + @browser.link(:id, ele).click + + when @browser.link(:text, ele).exists? + @browser.link(:text, ele).click + + when @browser.link(:class, ele).exists? + @browser.link(:class, ele).click + + when @browser.link(:href, ele).exists? + @browser.link(:href, ele).click + + else + fail("Link => #{ele} NOT FOUND") + end +end + +###### Span +Given(/^I click the "(.*?)" span$/) do |ele| + case + when @browser.span(:id, ele).exists? + @browser.span(:id, ele).click + + when @browser.span(:text, ele).exists? + @browser.span(:text, ele).click + + when @browser.span(:class, ele).exists? + @browser.span(:class, ele).click + + else + fail("Span => #{ele} NOT FOUND") + end +end + +###### Icon +Given(/^I click the "(.*?)" icon$/) do |ele| + case + when @browser.i(:id, ele).exists? + @browser.i(:id, ele).click + + when @browser.i(:text, ele).exists? + @browser.i(:text, ele).click + + when @browser.i(:class, ele).exists? + @browser.i(:class, ele).click + + else + fail("Icon => #{ele} NOT FOUND") + end +end + +Given(/^I wait for the menu to be displayed$/) do + @browser.ul(:class => "off-canvas-list").wait_until_present +end +Given(/^I wait for the form name "(.*?)"$/) do |arg1| + @browser.form(:name => arg1).wait_until_present +end + +Given(/^I click the "(.*?)" bs popover$/) do |arg1| + @browser.button(:text => button_text).click +end + +Given(/^I click the "(.*?)" path class$/) do |arg1| + @browser.div(:class => "uv.bubble-foreground").click +end + +Given(/^I click the "(.*?)" h(\d+)$/) do |arg1, arg2| + @browser.div(:class => 'container').h4(:text => arg1).click +end + +Then(/^I must see the "(.*?)" text field has a class attribute of "(.*?)"$/) do |textfield_name, attribute| + class_attr_values = @browser.input(:name,textfield_name).attribute_value('class') + assert_includes(class_attr_values,attribute) +end diff --git a/features/step_definitions/example_steps.rb b/features/step_definitions/example_steps.rb deleted file mode 100644 index ae52f0e..0000000 --- a/features/step_definitions/example_steps.rb +++ /dev/null @@ -1,29 +0,0 @@ -Given(/^I wait for the form name "(.*?)"$/) do |arg1| - @browser.form(:name => arg1).wait_until_present -end - -Given(/^I click the "(.*?)" bs popover$/) do |arg1| - @browser.button(:text => button_text).click -end - -Given(/^I click the "(.*?)" path class$/) do |arg1| - @browser.div(:class => "uv.bubble-foreground").click -end - -Given(/^I click the "(.*?)" topics$/) do |arg1| - #@browser.div(:class => 'container').h4(:text => arg1).click - @browser.link("ui-sref" => / kickstart.topic /).click -end - -Given(/^I click the "(.*?)" icon$/) do |arg1| - @browser.div(:class =>"uv-icon uv-bottom-right").click -end - -Given(/^I click the "(.*?)" h(\d+)$/) do |arg1, arg2| - @browser.div(:class => 'container').h4(:text => arg1).click -end - -Then(/^I must see the "(.*?)" text field has a class attribute of "(.*?)"$/) do |textfield_name, attribute| - class_attr_values = @browser.input(:name,textfield_name).attribute_value('class') - assert_includes(class_attr_values,attribute) -end \ No newline at end of file diff --git a/features/step_definitions/myapp_steps.rb b/features/step_definitions/myapp_steps.rb deleted file mode 100644 index e4cf1ed..0000000 --- a/features/step_definitions/myapp_steps.rb +++ /dev/null @@ -1,66 +0,0 @@ -Given(/^I am on the moduscreate home page$/) do - puts "Test running against #{BASE_URL}" - @browser.goto(BASE_URL) -end - -Then(/^I must see the page title "(.*?)"$/) do |title| - assert_equal(title,@browser.title) -end - -###### Links -Given(/^I click the "(.*?)" link$/) do |ele| - case - when @browser.link(:id, ele).exists? - @browser.link(:id, ele).click - - when @browser.link(:text, ele).exists? - @browser.link(:text, ele).click - - when @browser.link(:class, ele).exists? - @browser.link(:class, ele).click - - when @browser.link(:href, ele).exists? - @browser.link(:href, ele).click - - else - fail("Link => #{ele} NOT FOUND") - end -end - -###### Span -Given(/^I click the "(.*?)" span$/) do |ele| - case - when @browser.span(:id, ele).exists? - @browser.span(:id, ele).click - - when @browser.span(:text, ele).exists? - @browser.span(:text, ele).click - - when @browser.span(:class, ele).exists? - @browser.span(:class, ele).click - - else - fail("Span => #{ele} NOT FOUND") - end -end - -###### Icon -Given(/^I click the "(.*?)" icon$/) do |ele| - case - when @browser.i(:id, ele).exists? - @browser.i(:id, ele).click - - when @browser.i(:text, ele).exists? - @browser.i(:text, ele).click - - when @browser.i(:class, ele).exists? - @browser.i(:class, ele).click - - else - fail("Icon => #{ele} NOT FOUND") - end -end - -Given(/^I wait for the menu to b displayed$/) do - @browser.ul(:class => "off-canvas-list").wait_until_present -end diff --git a/features/support/hooks.rb b/features/support/hooks.rb index c5c36db..528ca20 100644 --- a/features/support/hooks.rb +++ b/features/support/hooks.rb @@ -48,6 +48,15 @@ def get_browser end end +Before ('@tablet') do + @browser = get_browser + if DRIVER == "chrome" + @browser.window.resize_to(1024,768) + else + @browser.window.maximize + end +end + After do @browser.close end