ds-gui-automation 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source 'http://gems.despegar.com'
2
+ source 'https://rubygems.org'
3
+
4
+ gem 'watir-webdriver'
5
+ gem 'cucumber'
6
+ gem 'rake'
7
+ gem 'rspec'
8
+ gem 'httparty'
9
+ gem 'henry-container', "~> 0.1.39"#, :path => '~/projects/henry/core/ruby-container'
10
+ gem 'nokogiri'
11
+ gem 'i18n-date'
12
+ gem 'chunky_png'
13
+
14
+ group :development do
15
+ gem 'debugger'
16
+ gem 'pry'
17
+ gem 'pry-doc'
18
+ gem 'pry-nav'
19
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/ds/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "ds-gui-automation"
6
+ gem.version = DestinationServicesGUI::VERSION
7
+ gem.authors = ["Santiago Ochoa"]
8
+ gem.email = %w{sochoa@despegar.com}
9
+ gem.description = %q{DS Services testing Gem}
10
+ gem.summary = %q{Automation Testing for DS Services}
11
+ gem.homepage = "http://gems.despegar.com"
12
+ gem.files = Dir[".henry/**/*.*"] +
13
+ Dir["ds-gui-automation.gemspec"] +
14
+ Dir["Gemfile"] +
15
+ Dir['features/**/*.rb'] +
16
+ Dir['features/**/*.feature'] +
17
+ Dir['henry-context.yml'] +
18
+ Dir['lib/**/*.rb']
19
+
20
+ gem.add_dependency('henry-container', '>= 0.1.39')
21
+ gem.add_dependency('cucumber')
22
+ gem.add_dependency('watir-webdriver')
23
+ gem.add_dependency('cucumber')
24
+ gem.add_dependency('httparty')
25
+
26
+ end
@@ -0,0 +1,8 @@
1
+ Feature: Destination Services Detail
2
+ As a user,
3
+ I want to be able to enter the detail of an activity.
4
+
5
+ @detail_disney
6
+ Scenario: Disney detail price validation
7
+ Given I'm on the ticket's detail
8
+ Then I should see the detail page with the corresponding prices for each ticket
@@ -0,0 +1,18 @@
1
+ Feature: Destination Services Search
2
+ As a user,
3
+ I want to be able to perform a search with the parameters I specify.
4
+
5
+ Scenario: Perform a Search from the Activities's home
6
+ Given I'm on the Activities's home search box
7
+ When I set the parameters on the search box and click the search button
8
+ Then I should see the results page with the search result
9
+
10
+ @search
11
+ Scenario: Perform a Search from the Activities's home
12
+ Given I'm on the Result's page
13
+ Then I should see the results page with the search result
14
+
15
+ Scenario: Perform a Search from the Re-Search box
16
+ Given I'm on the Results Page
17
+ When I set the parameters on the re search box and click the search button
18
+ Then I should see the results page with the search result
@@ -0,0 +1,19 @@
1
+ Given(/^I'm on the ticket's detail$/) do
2
+ DestinationServicesGUI::Detail.go_ticket_detail(TRACKING_ID)
3
+ end
4
+
5
+ Then(/^I should see the detail page with the corresponding prices for each ticket$/) do
6
+
7
+ hot_modality_price = DestinationServicesGUI::Detail.get_hot_modality_price
8
+
9
+ multiple_day_price = DestinationServicesGUI::Detail.get_random_multiple_day_ticket_price
10
+
11
+ one_day_price = DestinationServicesGUI::Detail.get_random_one_day_ticket_price
12
+
13
+ (hot_modality_price.eql?(multiple_day_price)).should be_false
14
+
15
+ (one_day_price.eql?(multiple_day_price)).should be_false
16
+
17
+ (hot_modality_price.eql?(one_day_price)).should be_false
18
+
19
+ end
@@ -0,0 +1,35 @@
1
+ Given(/^I'm on the Activities's home search box$/) do
2
+ DestinationServicesGUI::Search.go_home
3
+ end
4
+
5
+ Given(/^I'm on the Result's page$/) do
6
+ DestinationServicesGUI::Search.go_to_activities
7
+ end
8
+
9
+ When(/^I set the parameters on the search box and click the search button$/) do
10
+ DestinationServicesGUI::Search.perform_search
11
+ end
12
+
13
+ Then(/^I should see the results page with the search result$/) do
14
+
15
+ puts " URL: #{@browser.url} "
16
+
17
+ Watir::Wait.until(timeout = 300){@browser.div(:class, 'ux-common-results-main').present?}
18
+
19
+ sleep(45)
20
+
21
+ puts " Results => #{@browser.divs(:class, 'ux-destination-services-cluster').size}"
22
+
23
+ (@browser.divs(:class, 'ux-destination-services-cluster').size > 0 ).should be_true
24
+
25
+ @browser.div(:id, 'ux-destination-services-filters').should be_visible
26
+ @browser.div(:class, 'seo-texts').should be_visible
27
+ @browser.select_list(:id, 'ux-select-order').should be_visible
28
+ @browser.div(:class, 'pdt-activities').should be_visible
29
+ @browser.div(:class, 'ux-common-breadcrumbs').should be_visible
30
+ @browser.div(:class, 'ux-common-results-title').should be_visible
31
+ results_quantity = @browser.div(:class, 'ux-common-results-title').text.split.first.to_i
32
+ @browser.div(:class, 'cp-pager ng-isolate-scope').should be_visible if results_quantity > 20
33
+
34
+
35
+ end
@@ -0,0 +1,104 @@
1
+ #encoding: utf-8
2
+
3
+ require 'watir-webdriver'
4
+ require 'chunky_png'
5
+ require 'date'
6
+ require 'cucumber/formatter/unicode'
7
+ require 'rspec/expectations'
8
+ require 'pry'
9
+ require 'singleton'
10
+ require 'httparty'
11
+ require 'henry/environment'
12
+ require 'henry/config'
13
+ #require 'productos_combinados'
14
+
15
+ # require_relative '../../lib/data.rb'
16
+ # require_relative '../../lib/helpers.rb'
17
+ require_relative '../../lib/ds-gui-automation.rb'
18
+ # require_relative '../../lib/classes/date.rb'
19
+ # require_relative '../../lib/classes/logger.rb'
20
+ # require_relative '../../lib/classes/result.rb'
21
+ # require_relative '../../lib/ticket_state/state.rb'
22
+
23
+ DOMAIN = {}
24
+ params = Henry::Environment.params
25
+
26
+ DOMAIN = params['environment']['site'] || %W{www.despegar.com.bo www.despegar.com.uy www.despegar.com.sv www.despegar.com.sv www.despegar.com.gt www.despegar.com.hn www.despegar.com.ni www.despegar.com.pa www.despegar.com.py www.despegar.com.do www.us.despegar.com www.despegar.com.ve}.shuffle.first
27
+ COUNTRY = params['country']
28
+ BROWSER = params['browser'] || 'chrome'
29
+ WAIT_TIMEOUT = params['timeout'] || 150
30
+ BOT_UOW = params['botuow'] || 'DS-GUI-BOT'
31
+ TO_CITY = params['to_city'] || %W{BUE ORL CUN MIA NYC LAS}.shuffle.first
32
+ # FROM_CITY = params['from_city'] || get_origin_based_on_environment(ENVIRONMENT)
33
+ ON_MONTH = params['search_month'] || (Time.now + 2629743).strftime('%Y-%m')
34
+ WITH_DISTRIBUTION = params['distribution'] || rand(1..3).to_s
35
+ PROVIDER = params['provider'] || "CPSM"
36
+ BETA = params['beta']
37
+ BETA_FRONT = params['beta_front']
38
+ BETA_COOKIES = params['cookies'] || 'settings'
39
+ DRY_RUN = params['dry_run'] || true
40
+ MAX_RETRIES = params['max_retries'] || 3
41
+ TRACKING_ID = params['environment']['trackingId']
42
+ ## END OF SET-UP FROM HENRY
43
+
44
+ client = Selenium::WebDriver::Remote::Http::Default.new
45
+ client.timeout = 500
46
+
47
+
48
+ browser_outside = Watir::Browser.new BROWSER.to_sym, :http_client => client
49
+ browser_outside.cookies.clear
50
+
51
+ maximized = false
52
+ #CP.set_browser(browser_outside)
53
+
54
+ ## CUCUMBER SCENARIOS SET-UP
55
+ Before do | scenario |
56
+ #DestinationServicesGUI.clear_search_params
57
+ #DestinationServicesGUI.set_max_invalid_retries
58
+ str = '@Scenario: '
59
+ str << scenario.title if scenario.respond_to?('title')
60
+
61
+ #Logger << str
62
+
63
+ @browser = browser_outside || (Watir::Browser.new BROWSER.to_sym, :http_client => client)
64
+
65
+ # if !maximized
66
+ # browser_outside.driver.manage.window.maximize
67
+ # maximized = true
68
+ # end
69
+
70
+ browser_outside = @browser
71
+
72
+ DestinationServicesGUI.set_browser(@browser)
73
+
74
+ DestinationServicesGUI::Search.go_home
75
+
76
+ if BETA
77
+ DestinationServicesGUI.set_cookie({'X-Version-Override' => BETA_COOKIES})
78
+ end
79
+
80
+ DestinationServicesGUI.set_cookie('X-UOW' => BOT_UOW)
81
+
82
+
83
+ end
84
+
85
+ After do |scenario|
86
+
87
+ if scenario.failed?
88
+ output_path = Henry::Environment.output_path
89
+ Dir::mkdir("#{output_path}/screenshots") if not File.directory?("#{output_path}/screenshots")
90
+ screenshot_path = "#{output_path}/screenshots/#{Time.now.strftime('%Y%m%dT%H%M%S')}.png"
91
+ @browser.screenshot.save screenshot_path
92
+ end
93
+ #@state.reset_states
94
+ #not going to work with compares yet
95
+ at_exit do
96
+
97
+ browser_outside && browser_outside.exist? && browser_outside.close
98
+
99
+ # Logger.show
100
+
101
+ end
102
+
103
+ end
104
+ ##END CUCUMBER SCENARIOS SET-UP
data/henry-context.yml ADDED
@@ -0,0 +1,18 @@
1
+ tasks:
2
+ - name: Destination Services Search
3
+ class_name: Henry::Task::CucumberTask
4
+ options:
5
+ tags:
6
+ - search
7
+ reports:
8
+ - format: html
9
+ name: ${DATE}_${TASK_NAME}.html
10
+
11
+ - name: Disney Detail
12
+ class_name: Henry::Task::CucumberTask
13
+ options:
14
+ tags:
15
+ - detail_disney
16
+ reports:
17
+ - format: html
18
+ name: ${DATE}_${TASK_NAME}.html
@@ -0,0 +1,6 @@
1
+ require_relative "./ds/version.rb"
2
+ require_relative "./page_objects/ds_flow.rb"
3
+
4
+ module DestinationServicesGUI
5
+ CONFIG = {}
6
+ end
data/lib/ds/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module DestinationServicesGUI
2
+ VERSION = "0.1.11"
3
+ end
@@ -0,0 +1,11 @@
1
+ require_relative './modules/disney_detail.rb'
2
+ require_relative './modules/initialize.rb'
3
+ require_relative './modules/navigation.rb'
4
+ require_relative './modules/commons.rb'
5
+
6
+ module DestinationServicesGUI::Detail
7
+ extend Initialize
8
+ extend Navigation
9
+ extend DisneyDetail
10
+ extend Commons
11
+ end
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'singleton'
3
+ require 'rspec'
4
+ require 'nokogiri'
5
+ require 'open-uri'
6
+ require 'httparty'
7
+ require 'pry'
8
+
9
+ require_relative './navigation.rb'
10
+ require_relative './modules/initialize.rb'
11
+ require_relative './modules/navigation.rb'
12
+ require_relative './search.rb'
13
+ require_relative './detail.rb'
14
+
15
+ module DestinationServicesGUI
16
+
17
+ CONFIG = {}
18
+
19
+ extend Initialize
20
+
21
+ end
@@ -0,0 +1,10 @@
1
+ module Commons
2
+
3
+ def convert_to_city_name(iata)
4
+ geo_response = HTTParty.get("http://10.2.7.6/geo-services-web/service/webcontext/City/getCityByCityCode/#{iata}")
5
+ #geo_response = HTTParty.get("http://10.254.168.100/geo-services-web/service/webcontext/City/getCityByCityCode/#{iata}")
6
+ city_name = geo_response['data']['geoAreaDescriptions'].reject{|key| key if !key['languageCode'].eql?("ES")}[0]['name']
7
+ end
8
+
9
+
10
+ end
@@ -0,0 +1,58 @@
1
+ require_relative './commons.rb'
2
+
3
+ module DisneyDetail
4
+
5
+ def get_hot_modality_price
6
+
7
+ tickets_table = browser.lis(:class, 'ux-destination-services-detail-table-row')
8
+ hot_modality_price = tickets_table[1].li(:class, 'ux-destination-services-detail-table-price').text.split[1]
9
+
10
+ hot_modality_price
11
+
12
+ end
13
+
14
+ def get_multiple_day_ticket_price(li = 0)
15
+
16
+ tickets_table = browser.lis(:class, 'ux-destination-services-detail-table-row')
17
+
18
+ browser.input(:class, 'ux-destination-services-detail-table-days-input').click
19
+
20
+ browser.ul(:class, 'ux-destination-services-detail-table-days-list').lis[li].click
21
+
22
+ multiple_day_price = tickets_table[2].li(:class, 'ux-destination-services-detail-table-price').text.split[1]
23
+
24
+ multiple_day_price
25
+
26
+ end
27
+
28
+ def get_random_multiple_day_ticket_price
29
+
30
+ li = [0,1,3,4,5,6,7]
31
+
32
+ li = li.shuffle.pop
33
+
34
+ get_multiple_day_ticket_price(li)
35
+
36
+ end
37
+
38
+ def get_one_day_ticket_price(input = 0)
39
+
40
+ tickets_table = browser.lis(:class, 'ux-destination-services-detail-table-row')
41
+
42
+ browser.ul(:class, 'ux-destination-services-detail-table-parks').inputs[input].click
43
+
44
+ one_day_price = tickets_table[3].li(:class, 'ux-destination-services-detail-table-price').text.split[1]
45
+
46
+ one_day_price
47
+
48
+ end
49
+
50
+ def get_random_one_day_ticket_price
51
+
52
+ input = [0,1].shuffle.pop
53
+
54
+ get_one_day_ticket_price(input)
55
+
56
+ end
57
+
58
+ end
@@ -0,0 +1,32 @@
1
+
2
+ module Initialize
3
+
4
+ attr_reader :browser
5
+
6
+ def clear_search_params
7
+ DestinationServicesGUI::CONFIG[:search_params] = {}
8
+ end
9
+
10
+ def search_params
11
+ DestinationServicesGUI::CONFIG[:search_params]
12
+ end
13
+
14
+ def set_browser(browser)
15
+ DestinationServicesGUI::CONFIG[:browser] = browser
16
+ end
17
+
18
+ def browser
19
+ DestinationServicesGUI::CONFIG[:browser]
20
+ end
21
+
22
+ def set_cookie(data = {})
23
+ if data.nil? || data.empty?
24
+ raise('Cookies should have a name and value')
25
+ end
26
+
27
+ data.each do | key, value |
28
+ browser.cookies.add(key.to_s, value.to_s, :path => '/')
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,39 @@
1
+ module Navigation
2
+
3
+ def go_home
4
+
5
+ url = ''
6
+ url = get_domain_by_country
7
+ browser.goto(url) if !on_url(url)
8
+
9
+ end
10
+
11
+ def go_to_activities
12
+ date = (Time.now + 2629743).strftime('%Y-%m')
13
+ destination = TO_CITY
14
+ url = DOMAIN + "/actividades/shopping#!/search/#{destination}/#{date}/1"
15
+
16
+ browser.goto(url)
17
+
18
+ end
19
+
20
+ def go_ticket_detail(trackingId)
21
+
22
+ url = ''
23
+ url = get_domain_by_country + "/d-#{trackingId}"
24
+
25
+ browser.goto(url)
26
+
27
+ end
28
+
29
+ def on_url(url)
30
+ entire_url = 'http://' + url
31
+ browser.url.eql?("#{entire_url}")
32
+ end
33
+
34
+ def get_domain_by_country
35
+ !DOMAIN.include?('decolar') ? (url = DOMAIN + '/actividades/') : (url = DOMAIN + '/atracoes-turisticas/')
36
+ url
37
+ end
38
+
39
+ end
@@ -0,0 +1,49 @@
1
+ require_relative './commons.rb'
2
+
3
+ module Search
4
+
5
+ def perform_search(destination = nil, date = nil)
6
+
7
+ search_box = browser.div(:class, 'pdt-activities')
8
+
9
+ destination = DestinationServicesGUI::Search.convert_to_city_name(TO_CITY)
10
+
11
+ dates = []
12
+
13
+ date_select = browser.div(:class, 'com-month-activities').select(:class, 'sb-month')
14
+
15
+ if date.nil?
16
+ dates = date_select.options.to_a
17
+ dates = dates.collect{ | d | d.text }
18
+ dates = dates[1..5]
19
+ date = dates.shuffle.pop
20
+ end
21
+
22
+ adults ||= 2
23
+
24
+ children ||= 2
25
+
26
+ destination_field = browser.text_field(:id, 'sb-destination-activities')
27
+ destination_field.set(destination)
28
+ sleep(8) # implementar wait para el servicio de autocomplete
29
+ binding.pry
30
+ search_box.div(:class,'com-city-hotels destination').uls.first.li(:class, 'first').click
31
+
32
+ date_select.select(date)
33
+
34
+ browser.select_list(:class, 'adult').select(adults) if adults > 0
35
+
36
+ if children > 0
37
+ search_box.select_list(:class, 'child').select(children)
38
+ 1.upto (children) do |n|
39
+ search_box.li(:class, "ctn-#{n}").select_list(:class, 'sb-age').select(rand(3..9))
40
+ end
41
+ end
42
+
43
+ puts " TO_CITY: #{TO_CITY} "
44
+
45
+ search_box.a(:class, 'ctn-searchbutton').click
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,5 @@
1
+ require_relative './modules/navigation.rb'
2
+
3
+ module DestinationServicesGUI::Navigation
4
+ extend Navigation
5
+ end
@@ -0,0 +1,11 @@
1
+ require_relative './modules/search.rb'
2
+ require_relative './modules/initialize.rb'
3
+ require_relative './modules/navigation.rb'
4
+ require_relative './modules/commons.rb'
5
+
6
+ module DestinationServicesGUI::Search
7
+ extend Initialize
8
+ extend Navigation
9
+ extend Search
10
+ extend Commons
11
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ds-gui-automation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.11
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Santiago Ochoa
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-08-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: henry-container
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.39
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.39
30
+ - !ruby/object:Gem::Dependency
31
+ name: cucumber
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: watir-webdriver
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: cucumber
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: httparty
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: DS Services testing Gem
95
+ email:
96
+ - sochoa@despegar.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - ds-gui-automation.gemspec
102
+ - Gemfile
103
+ - features/step_definitions/detail_steps.rb
104
+ - features/step_definitions/search_steps.rb
105
+ - features/support/env.rb
106
+ - features/detail.feature
107
+ - features/search.feature
108
+ - henry-context.yml
109
+ - lib/ds-gui-automation.rb
110
+ - lib/page_objects/search.rb
111
+ - lib/page_objects/ds_flow.rb
112
+ - lib/page_objects/modules/disney_detail.rb
113
+ - lib/page_objects/modules/search.rb
114
+ - lib/page_objects/modules/initialize.rb
115
+ - lib/page_objects/modules/commons.rb
116
+ - lib/page_objects/modules/navigation.rb
117
+ - lib/page_objects/detail.rb
118
+ - lib/page_objects/navigation.rb
119
+ - lib/ds/version.rb
120
+ homepage: http://gems.despegar.com
121
+ licenses: []
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 1.8.25
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: Automation Testing for DS Services
144
+ test_files: []
145
+ has_rdoc: