Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9b150d0
Showing
14 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea/ | ||
Gemfile.lock | ||
results.html | ||
test.rb | ||
screenshots/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'cucumber' | ||
gem 'rspec' | ||
gem 'selenium-webdriver' | ||
gem 'watir-webdriver' | ||
gem 'require_all' | ||
gem 'activesupport' | ||
|
||
|
||
# gem to connect to saucelabs and also dynamically change browser parameters | ||
gem 'saucelabs' | ||
|
||
gem 'nokogiri' | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2014 Pradeep K. Macharla | ||
|
||
MIT License | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Training | ||
======== | ||
|
||
This project is being used to demonstrate modules or keyword framework pattern for Test Automation in Ruby | ||
|
||
Instruction to use | ||
=================== | ||
1) Install Ruby (1.9 or higher) | ||
2) gem install cucumber | ||
3) gem install bundler | ||
4) check out the project | ||
5) From project root folder, "bundle exec cucumber features" | ||
|
||
|
||
Known Issues | ||
===================== | ||
Hooks.rb code launches browser even for non-browser scenarios, however it closes it down too | ||
|
||
|
||
Instructions to use | ||
===================== | ||
|
||
1) Checkout the project | ||
2) Run bundle install | ||
3) Go through .feature files | ||
4) Check step defnitions | ||
|
||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'rubygems' | ||
require 'cucumber' | ||
require 'cucumber/rake/task' | ||
|
||
Cucumber::Rake::Task.new(:features) do |t| | ||
t.profile = 'default' | ||
end | ||
|
||
task :default => :features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default: --no-source --color --format pretty --format html --out results.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Feature: Sign in and contact us | ||
|
||
Scenario: Successful login | ||
When I open "http://automationpractice.com" website | ||
Then I login using credentials "abc@xyz.com" and "Test@123" | ||
|
||
Scenario: unsuccessful login | ||
When I open "http://automationpractice.com" website | ||
Then I login using credentials "abc@xyz1.com" and "Test@123" | ||
|
||
Scenario: Contact us | ||
When I open "http://automationpractice.com" website | ||
Then I contact customer service with order reference "abc123" and message "hello there" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
When(/^I open "([^"]*)" website$/) do |url| | ||
visit url | ||
end | ||
|
||
Then(/^I login using credentials "([^"]*)" and "([^"]*)"$/) do |username, password| | ||
sign_in(username,password) | ||
end | ||
|
||
Then(/^I contact customer service with order reference "([^"]*)" and message "([^"]*)"$/) do |order_ref, message| | ||
contact_customer_service(order_ref,message) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'watir-webdriver' | ||
require 'rspec' | ||
require 'require_all' | ||
require 'saucelabs' | ||
require 'nokogiri' | ||
|
||
require './lib/data_helper' | ||
require './features/support/modules/business_modules' | ||
|
||
OR = YAML.load_file './lib/config/object_repository.yml' | ||
|
||
|
||
World DataHelper | ||
World Keywords | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'watir-webdriver' | ||
require 'selenium-webdriver' | ||
include SauceLabs | ||
|
||
|
||
Before do | ||
|
||
ENV['BROWSER'] = "chrome" if ENV['BROWSER'].nil? | ||
if(ENV['BROWSER']=='firefox') | ||
profile = Selenium::WebDriver::Firefox::Profile.from_name 'seleniumprofile' | ||
@browser = Watir::Browser.new :firefox, :profile => profile | ||
else | ||
@browser = Watir::Browser.new ENV['BROWSER'].to_sym | ||
end | ||
@browser.window.maximize | ||
end | ||
|
||
|
||
After do |scenario| | ||
if scenario.failed? | ||
Dir::mkdir('screenshots') if not File.directory?('screenshots') | ||
screenshot = "./screenshots/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png" | ||
@browser.driver.save_screenshot(screenshot) | ||
embed screenshot, 'image/png' | ||
end | ||
@browser.cookies.clear | ||
@browser.quit | ||
|
||
end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Keywords | ||
|
||
def visit url | ||
@browser.goto url | ||
end | ||
|
||
def sign_in(username,password) | ||
@browser.link(text: OR['signin_text']).click | ||
@browser.text_field(id: OR['username_id']).set username | ||
@browser.text_field(id: OR['password_id']).set password | ||
@browser.button(id: OR['submit_login_id']).click | ||
expect(@browser.link(text: "Sign out").present?).to be_truthy | ||
end | ||
|
||
def contact_customer_service(order_ref,message) | ||
@browser.link(text: OR['contact_us_text']).click | ||
|
||
@browser.select(id: OR['subject_heading_id']).select "Customer service" | ||
@browser.text_field(id: OR['email_id']).set "pradeep@seleniumframework.com" | ||
@browser.text_field(id: OR['order_reference_id']).set order_ref | ||
@browser.text_field(id: OR['message_id']).set message | ||
@browser.button(id: OR['submit_message_id']).click | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
username: abc@xyz.com | ||
password: Test@123 | ||
order_reference: 123456 | ||
message: Keyword driven framework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
signin_text: Sign in | ||
username_id: email | ||
password_id: passwd | ||
submit_login_id: SubmitLogin | ||
|
||
contact_us_text: Contact us | ||
subject_heading_id: id_contact | ||
email_id: email | ||
order_reference_id: id_order | ||
message_id: message | ||
submit_message_id: submitMessage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module DataHelper | ||
|
||
# Read basics on YAML - http://www.seleniumframework.com/test-data/test-data-with-yaml/ | ||
def data_yml_hash | ||
@data_yml = YAML.load_file "#{data_default_directory}/#{yml_file}" | ||
end | ||
|
||
# Read basics on excel parsing - http://www.seleniumframework.com/test-data/test-data-with-excel/ | ||
def data_excel_hash (data_sheet) | ||
workbook = RubyXL::Parser.parse data_default_directory+'/'+excel_file | ||
sheet = workbook[data_sheet] | ||
header_row = sheet.sheet_data[0] | ||
@data_excel = sheet.get_table(header_row) | ||
end | ||
|
||
# Json parsing reference - http://www.seleniumframework.com/test-data/test-data-with-json/ | ||
def data_json_hash | ||
@data_json = JSON.parse data_default_directory+'/'+json_file | ||
end | ||
|
||
def set_data_directory(dir) | ||
@data_directory = dir | ||
end | ||
|
||
|
||
private | ||
|
||
def yml_file | ||
ENV['DATA_YML_FILE']? ENV['DATA_YML_FILE'] : 'default.yml' | ||
end | ||
|
||
def excel_file | ||
ENV['DATA_EXCEL_FILE']?ENV['DATA_EXCEL_FILE'] : 'default.xlsx' | ||
end | ||
|
||
def json_file | ||
ENV['DATA_JSON_FILE']?ENV['DATA_JSON_FILE'] : 'default.json' | ||
end | ||
|
||
def xml_file | ||
ENV['DATA_XML_FILE']?ENV['DATA_XML_FILE'] : 'default.xml' | ||
end | ||
|
||
|
||
def data_default_directory | ||
@data_directory ||= 'lib/config/data' | ||
end | ||
|
||
|
||
class << self | ||
|
||
attr_accessor :data_yml,:data_excel,:data_json,:data_xml, :data_directory | ||
|
||
end | ||
|
||
|
||
|
||
end |