From c91aef43faaa4bb8c42715993e0ae8a8b6df3115 Mon Sep 17 00:00:00 2001 From: bkone Date: Sun, 23 Mar 2014 07:58:15 -0700 Subject: [PATCH 1/4] Initial commit --- LICENSE | 21 +++++++++++++++++++++ README.md | 4 ++++ 2 files changed, 25 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ad865d4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 bkone + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e297053 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +cukeit +====== + +Test harness using cucumber+watirwebdriver From e3dc571c62a2c74e9b65885eb287c8358f771866 Mon Sep 17 00:00:00 2001 From: Bharath Date: Wed, 2 Apr 2014 17:33:42 -0400 Subject: [PATCH 2/4] Initial Commit --- Gemfile | 9 + Gemfile.lock | 39 ++ README.md | 49 ++- Rakefile | 43 +++ config.yml | 1 + features/step_definitions/myapp_steps.rb | 49 +++ features/support/app_url.rb | 6 + features/support/peg.rb | 22 ++ features/test.feature | 25 ++ results/all-report.html | 472 +++++++++++++++++++++++ 10 files changed, 712 insertions(+), 3 deletions(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Rakefile create mode 100644 config.yml create mode 100644 features/step_definitions/myapp_steps.rb create mode 100644 features/support/app_url.rb create mode 100644 features/support/peg.rb create mode 100644 features/test.feature create mode 100644 results/all-report.html diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..291dd3d --- /dev/null +++ b/Gemfile @@ -0,0 +1,9 @@ +source 'http://rubygems.org' + +ruby "2.1.1" + +gem 'cucumber' +gem 'watir-webdriver' +gem 'bundler' +gem 'rake' +gem 'minitest' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..e776955 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,39 @@ +GEM + remote: http://rubygems.org/ + specs: + builder (3.2.2) + childprocess (0.5.1) + ffi (~> 1.0, >= 1.0.11) + cucumber (1.3.12) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.12) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.1) + diff-lcs (1.2.5) + ffi (1.9.3) + gherkin (2.12.2) + multi_json (~> 1.3) + minitest (4.7.5) + multi_json (1.9.2) + multi_test (0.1.1) + rake (10.1.1) + rubyzip (1.1.2) + selenium-webdriver (2.40.0) + childprocess (>= 0.5.0) + multi_json (~> 1.0) + rubyzip (~> 1.0) + websocket (~> 1.0.4) + watir-webdriver (0.6.8) + selenium-webdriver (>= 2.18.0) + websocket (1.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + bundler + cucumber + minitest + rake + watir-webdriver diff --git a/README.md b/README.md index e297053..4b7728f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,47 @@ -cukeit -====== +# cukeit +cuke it is a cucumber watirwebdriver bootstrap which can help you quickly get started with writing tests against any application. -Test harness using cucumber+watirwebdriver + +##Getting Started (Mac) + +#### Install Xcode + +#### Install Homebrew +`ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"` +#### Install RVM +`\curl -sSL https://get.rvm.io | bash -s stable` + +#### Install Ruby using RVM +`rvm install ruby-2.1.1` + +#### Clone this repo +`git clone git@github.com:bkone/cukeit.git` + +#### Install the Bundler gem +`gem install bundler --no-ri --no-rdoc` + +#### Install Chromedriver using brew or npm +`brew install chromedriver` + +or + +`npm install chromedriver -g` + +#### Install all the dependencies +`cd cukeit` + +`bundle install` + +#### Run Rake +`rake` + +##Getting Started (Windows) +#### Download and Install Ruby +`http://rubyinstaller.org/downloads/` + +#### Download and install chromedriver +`http://chromedriver.storage.googleapis.com/index.html` + +~Make sure the chromedrives is in your path~ + +#### From here you can follow the same instructions as above. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..50fcb37 --- /dev/null +++ b/Rakefile @@ -0,0 +1,43 @@ +require 'cucumber/rake/task' + + +Cucumber::Rake::Task.new(:all, 'Runs the whole test Suite') do |t| + t.cucumber_opts = "features/* + --format html --out=results/all-report.html + --format pretty --no-source" +end + +Cucumber::Rake::Task.new(:regression, 'Runs the whole test Suite') do |t| + t.cucumber_opts = "features/* + --format html --out=results/regression-report.html + --format pretty --no-source + --tag @regression" +end + +Cucumber::Rake::Task.new(:regression, 'Runs test tagged as regression') do |t| + t.cucumber_opts = "features/* + --format html --out=results/regression-report.html + --format pretty --no-source + --tag @regression" +end + +Cucumber::Rake::Task.new(:desktop, 'Runs test tagged as Desktop') do |t| + t.cucumber_opts = "features/* + --format html --out=results/desktop-report.html + --format pretty --no-source + --tag @desktop" +end + +Cucumber::Rake::Task.new(:mobile, 'Runs test tagged as Mobile') do |t| + t.cucumber_opts = "features/* + --format html --out=results/mobile-report.html + --format pretty --no-source + --tag @mobile" +end + +Cucumber::Rake::Task.new(:tablet, 'Runs test tagged as tablet') do |t| + t.cucumber_opts = "features/* + --format html --out=results/tablet-report.html + --format pretty --no-source + --tag @tablet" +end diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..ada88ff --- /dev/null +++ b/config.yml @@ -0,0 +1 @@ +default: --tags ~@wip --require features diff --git a/features/step_definitions/myapp_steps.rb b/features/step_definitions/myapp_steps.rb new file mode 100644 index 0000000..b237164 --- /dev/null +++ b/features/step_definitions/myapp_steps.rb @@ -0,0 +1,49 @@ +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 |link_attr| + case + when @browser.link(:id, link_attr).exists? + @browser.link(:id, link_attr).click + + when @browser.link(:text, link_attr).exists? + @browser.link(:text, link_attr).click + + when @browser.link(:class, link_attr).exists? + @browser.link(:class, link_attr).click + + when @browser.link(:href, link_attr).exists? + @browser.link(:href, link_attr).click + + else + fail("Link => #{link_attr} 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 + +Given(/^I wait for the menu to b displayed$/) do + @browser.ul(:class => "menuNavUl").wait_until_present +end diff --git a/features/support/app_url.rb b/features/support/app_url.rb new file mode 100644 index 0000000..ca2021c --- /dev/null +++ b/features/support/app_url.rb @@ -0,0 +1,6 @@ +require 'watir-webdriver' +require 'minitest/unit' + +BASE_URL = "http://moduscreate.com" + +World(MiniTest::Assertions) diff --git a/features/support/peg.rb b/features/support/peg.rb new file mode 100644 index 0000000..8097a94 --- /dev/null +++ b/features/support/peg.rb @@ -0,0 +1,22 @@ +# For more information on writing hooks please read the cuke wiki +# https://github.com/cucumber/cucumber/wiki/Hooks + +# Tagged Hooks +Before('@desktop') do + @browser = Watir::Browser.new(:chrome) +end + +Before('@mobile') do + @browser = Watir::Browser.new(:chrome) + @browser.window.resize_to(640,960) +end + +Before('@tablet') do + @browser = Watir::Browser.new(:chrome) + @browser.window.resize_to(1024,768) +end + + +After do + @browser.close +end diff --git a/features/test.feature b/features/test.feature new file mode 100644 index 0000000..d734ff7 --- /dev/null +++ b/features/test.feature @@ -0,0 +1,25 @@ +Feature: My Awesome feature + +@regression @desktop +Scenario: My completed desktop feature + Given I am on the moduscreate home page + Then I must see the page title "Modus Create | HTML5 Application Development & Training" + Given I click the "Services" link + Then I must see the page title "Services | Modus Create" + + +@regression @mobile +Scenario: My test which ready to run against mobile platform + Given I am on the moduscreate home page + Then I must see the page title "Modus Create | HTML5 Application Development & Training" + Given I click the "MENU" span + And I wait for the menu to b displayed + And I click the "Services" link + Then I must see the page title "Services | Modus Create" + +@wip @tablet +Scenario: My work in progress test + Given I am on the moduscreate home page + Then I must see the page title "Modus Create | HTML5 Application Development & Training" + Given I click the "Blog" link + Then I must see the page title "Blog | Modus Create" diff --git a/results/all-report.html b/results/all-report.html new file mode 100644 index 0000000..2f798e8 --- /dev/null +++ b/results/all-report.html @@ -0,0 +1,472 @@ +Cucumber

Cucumber Features

Expand All

Collapse All

Feature: My Awesome feature

@regression @desktopfeatures/test.feature:4

Scenario: My completed desktop feature

  1. Given I am on the moduscreate home page
    features/step_definitions/myapp_steps.rb:1
  2. Test running against http://moduscreate.com
  3. Then I must see the page title "Modus Create | HTML5 Application Development & Training"
    features/step_definitions/myapp_steps.rb:6
  4. Given I click the "Services" link
    features/step_definitions/myapp_steps.rb:11
  5. Then I must see the page title "Services | Modus Create"
    features/step_definitions/myapp_steps.rb:6
@regression @mobilefeatures/test.feature:12

Scenario: My test which ready to run against mobile platform

  1. Given I am on the moduscreate home page
    features/step_definitions/myapp_steps.rb:1
  2. Test running against http://moduscreate.com
  3. Then I must see the page title "Modus Create | HTML5 Application Development & Training"
    features/step_definitions/myapp_steps.rb:6
  4. Given I click the "MENU" span
    features/step_definitions/myapp_steps.rb:31
  5. And I wait for the menu to b displayed
    features/step_definitions/myapp_steps.rb:47
  6. And I click the "Services" link
    features/step_definitions/myapp_steps.rb:11
  7. Then I must see the page title "Services | Modus Create"
    features/step_definitions/myapp_steps.rb:6
@wip @tabletfeatures/test.feature:21

Scenario: My work in progress test

  1. Given I am on the moduscreate home page
    features/step_definitions/myapp_steps.rb:1
  2. Test running against http://moduscreate.com
  3. Then I must see the page title "Modus Create | HTML5 Application Development & Training"
    features/step_definitions/myapp_steps.rb:6
  4. Given I click the "Blog" link
    features/step_definitions/myapp_steps.rb:11
  5. Then I must see the page title "Blog | Modus Create"
    features/step_definitions/myapp_steps.rb:6
\ No newline at end of file From 250379f0a190de645153353a8e24ce2d12541aa3 Mon Sep 17 00:00:00 2001 From: Bharath Date: Wed, 14 May 2014 15:40:03 -0400 Subject: [PATCH 3/4] renamed hooks --- features/support/{peg.rb => hooks.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename features/support/{peg.rb => hooks.rb} (100%) diff --git a/features/support/peg.rb b/features/support/hooks.rb similarity index 100% rename from features/support/peg.rb rename to features/support/hooks.rb From 70fd7cbc24f206836483e7407cd506dc631784ab Mon Sep 17 00:00:00 2001 From: Bharath Date: Thu, 24 Jul 2014 09:01:55 -0400 Subject: [PATCH 4/4] fixed tests to run against the redesigned modus website --- Gemfile | 3 +- Gemfile.lock | 2 ++ features/step_definitions/myapp_steps.rb | 39 +++++++++++++++++------- features/support/{app_url.rb => env.rb} | 2 +- features/test.feature | 8 ++--- 5 files changed, 36 insertions(+), 18 deletions(-) rename features/support/{app_url.rb => env.rb} (75%) diff --git a/Gemfile b/Gemfile index 291dd3d..4192c7b 100644 --- a/Gemfile +++ b/Gemfile @@ -6,4 +6,5 @@ gem 'cucumber' gem 'watir-webdriver' gem 'bundler' gem 'rake' -gem 'minitest' \ No newline at end of file +gem 'minitest' +gem 'headless' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index e776955..a95c1a8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,6 +14,7 @@ GEM ffi (1.9.3) gherkin (2.12.2) multi_json (~> 1.3) + headless (1.0.1) minitest (4.7.5) multi_json (1.9.2) multi_test (0.1.1) @@ -34,6 +35,7 @@ PLATFORMS DEPENDENCIES bundler cucumber + headless minitest rake watir-webdriver diff --git a/features/step_definitions/myapp_steps.rb b/features/step_definitions/myapp_steps.rb index b237164..e4cf1ed 100644 --- a/features/step_definitions/myapp_steps.rb +++ b/features/step_definitions/myapp_steps.rb @@ -8,22 +8,22 @@ end ###### Links -Given(/^I click the "(.*?)" link$/) do |link_attr| +Given(/^I click the "(.*?)" link$/) do |ele| case - when @browser.link(:id, link_attr).exists? - @browser.link(:id, link_attr).click + when @browser.link(:id, ele).exists? + @browser.link(:id, ele).click - when @browser.link(:text, link_attr).exists? - @browser.link(:text, link_attr).click + when @browser.link(:text, ele).exists? + @browser.link(:text, ele).click - when @browser.link(:class, link_attr).exists? - @browser.link(:class, link_attr).click + when @browser.link(:class, ele).exists? + @browser.link(:class, ele).click - when @browser.link(:href, link_attr).exists? - @browser.link(:href, link_attr).click + when @browser.link(:href, ele).exists? + @browser.link(:href, ele).click else - fail("Link => #{link_attr} NOT FOUND") + fail("Link => #{ele} NOT FOUND") end end @@ -44,6 +44,23 @@ 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 => "menuNavUl").wait_until_present + @browser.ul(:class => "off-canvas-list").wait_until_present end diff --git a/features/support/app_url.rb b/features/support/env.rb similarity index 75% rename from features/support/app_url.rb rename to features/support/env.rb index ca2021c..9c3a3ba 100644 --- a/features/support/app_url.rb +++ b/features/support/env.rb @@ -3,4 +3,4 @@ BASE_URL = "http://moduscreate.com" -World(MiniTest::Assertions) +World(MiniTest::Assertions) \ No newline at end of file diff --git a/features/test.feature b/features/test.feature index d734ff7..68e0d21 100644 --- a/features/test.feature +++ b/features/test.feature @@ -4,7 +4,7 @@ Feature: My Awesome feature Scenario: My completed desktop feature Given I am on the moduscreate home page Then I must see the page title "Modus Create | HTML5 Application Development & Training" - Given I click the "Services" link + Given I click the "Services" span Then I must see the page title "Services | Modus Create" @@ -12,14 +12,12 @@ Scenario: My completed desktop feature Scenario: My test which ready to run against mobile platform Given I am on the moduscreate home page Then I must see the page title "Modus Create | HTML5 Application Development & Training" - Given I click the "MENU" span + Given I click the "icon-reorder" icon And I wait for the menu to b displayed - And I click the "Services" link - Then I must see the page title "Services | Modus Create" @wip @tablet Scenario: My work in progress test Given I am on the moduscreate home page Then I must see the page title "Modus Create | HTML5 Application Development & Training" - Given I click the "Blog" link + Given I click the "Blog" span Then I must see the page title "Blog | Modus Create"