ds-gui-automation 0.1.23 → 0.1.25

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/lib/ds/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DestinationServicesGUI
2
- VERSION = "0.1.23"
2
+ VERSION = "0.1.25"
3
3
  end
@@ -0,0 +1,11 @@
1
+ require_relative './modules/checkout.rb'
2
+ require_relative './modules/initialize.rb'
3
+ require_relative './modules/navigation.rb'
4
+ require_relative './modules/commons.rb'
5
+
6
+ module DestinationServicesGUI::Checkout
7
+ extend Initialize
8
+ extend Navigation
9
+ extend Commons
10
+ extend Checkout
11
+ end
@@ -1,4 +1,5 @@
1
1
  require_relative './modules/disney_detail.rb'
2
+ require_relative './modules/tour_detail.rb'
2
3
  require_relative './modules/initialize.rb'
3
4
  require_relative './modules/navigation.rb'
4
5
  require_relative './modules/commons.rb'
@@ -7,5 +8,6 @@ module DestinationServicesGUI::Detail
7
8
  extend Initialize
8
9
  extend Navigation
9
10
  extend DisneyDetail
11
+ extend TourDetail
10
12
  extend Commons
11
13
  end
@@ -5,6 +5,8 @@ require 'nokogiri'
5
5
  require 'open-uri'
6
6
  require 'httparty'
7
7
  require 'pry'
8
+ require 'active_support/core_ext/object/blank'
9
+ require 'debugger'
8
10
 
9
11
  require_relative './navigation.rb'
10
12
  require_relative './modules/initialize.rb'
@@ -12,6 +14,7 @@ require_relative './modules/navigation.rb'
12
14
  require_relative './search.rb'
13
15
  require_relative './results.rb'
14
16
  require_relative './detail.rb'
17
+ require_relative './checkout.rb'
15
18
 
16
19
  module DestinationServicesGUI
17
20
 
@@ -0,0 +1,100 @@
1
+ require_relative './commons.rb'
2
+
3
+ module Checkout
4
+
5
+ def fill_passenger_information
6
+
7
+ browser.text_field(:name, 'dsInputDefinition.passengerDefinitions[0].firstName.value').set('Diego QA')
8
+
9
+ browser.text_field(:name, 'dsInputDefinition.passengerDefinitions[0].lastName.value').set('Romero')
10
+
11
+ end
12
+
13
+ def fill_credit_card_information
14
+
15
+ browser.text_field(:id, 'card-number').set('4242424242424242')
16
+
17
+ browser.select_list(:id, 'card-expiration-month').select('2')
18
+
19
+ browser.select_list(:id, 'card-expiration-year').select('2017')
20
+
21
+ browser.text_field(:id, 'security-code').set('123')
22
+
23
+ browser.text_field(:id, 'owner-name').set('Diego QA Romero')
24
+
25
+ end
26
+
27
+ def fill_contact_information
28
+
29
+ if BETA
30
+ browser.text_field(:id, 'contact-email').set('oss_review@despegar.com')
31
+ browser.text_field(:id, 'contact-email-repeat').set('oss_review@despegar.com')
32
+ else
33
+ browser.text_field(:id, 'contact-email').set('oss_collect_ok@despegar.com')
34
+ browser.text_field(:id, 'contact-email-repeat').set('oss_collect_ok@despegar.com')
35
+ end
36
+
37
+ browser.text_field(:id, 'traveler-area-code-0').set('11')
38
+
39
+ browser.text_field(:id, 'traveler-phone-number-0').set('12345678')
40
+
41
+ browser.checkbox(:id, 'ux-common-checkoutchange-agreement-cb').click
42
+
43
+ end
44
+
45
+ def fill_pickup_information
46
+
47
+ browser.input(:id,'ux-destination-services-detail-hotel-tours-2').click if browser.div(:class, 'ux-destination-services-checkout-detail').present?
48
+
49
+ end
50
+
51
+ def fill_flight_information
52
+
53
+ browser.text_field(:id, 'arrival-flight-airline').set('Test Airline') if browser.text_field(:id, 'arrival-flight-airline').present?
54
+
55
+ browser.text_field(:id, 'arrival-flight-number').set('1234') if browser.text_field(:id, 'arrival-flight-number').present?
56
+
57
+ end
58
+
59
+ def get_ticket_dates
60
+
61
+ browser.div(:class,'ux-destination-services-contactinfo-date').click
62
+
63
+ browser.div(:class, 'datepicker').wait_until_present(20)
64
+
65
+ dates = []
66
+
67
+ sleep 1
68
+
69
+ dates = browser.div(:class, 'view days').table.tds(:class, 'in').select { | td | !td.a(:class, 'disabled').present? }
70
+
71
+ dates
72
+
73
+ end
74
+
75
+ def select_ticket_date
76
+
77
+ get_ticket_dates.last.click unless !browser.div(:class,'ux-destination-services-contactinfo-date').present?
78
+
79
+ end
80
+
81
+ def fill_risk_questions
82
+
83
+ if $SITE == 'AR'
84
+
85
+ else
86
+ i = 2
87
+ i.upto 8 do
88
+ browser.text_field(:name,"answerQuestions[#{i}].answer.text").set('Test') if browser.text_field(:name,"answerQuestions[#{i}].answer.text").present?
89
+ i += 1
90
+ end
91
+
92
+ sleep 1
93
+
94
+ browser.a(:id, 'securyty-form-btn').click if browser.a(:id, 'securyty-form-btn').present?
95
+
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -20,6 +20,41 @@ module Commons
20
20
 
21
21
  end
22
22
 
23
+ def get_tracking_id(cluster)
24
+
25
+ cluster = cluster.li(:class, 'providers').text.split(':').last.strip
26
+
27
+ cluster
28
+
29
+ end
30
+
31
+ def get_destination_from_tracking_id(trackingId)
32
+
33
+ trackingId.split('_')[1]
34
+
35
+ end
36
+
37
+ def set_country(country)
38
+ $SITE = country
39
+ set_domain
40
+ end
41
+
42
+ def set_domain
43
+ if $SITE == 'BR'
44
+ $DOMAIN='http://www.decolar.com'
45
+ elsif $SITE == 'CR'
46
+ $DOMAIN='http://www.despegar.co.cr'
47
+ elsif $SITE == 'CL'
48
+ $DOMAIN='http://www.despegar.cl'
49
+ elsif $SITE == 'US'
50
+ $DOMAIN='http://www.us.despegar.com'
51
+ else
52
+ $DOMAIN="http://www.despegar.com.#{$SITE.downcase}"
53
+ end
54
+
55
+ end
56
+
57
+
23
58
  def wait_for_results
24
59
 
25
60
  grid_results = browser.div(:class, 'ux-destination-services-cluster-grid')
@@ -28,9 +63,40 @@ module Commons
28
63
 
29
64
  timeout = 0
30
65
 
66
+ while !grid_results.present? and !cluster_results.present? and timeout < 60
67
+ sleep 3
68
+ timeout += 3
69
+ end
70
+
71
+ end
31
72
 
73
+ def wait_for_detail
32
74
 
33
- while !grid_results.present? and !cluster_results.present? and timeout < 60
75
+ timeout = 0
76
+
77
+ while !browser.div(:class, 'ux-destination-services-detail-pricebox').present? and timeout < 60
78
+ sleep 6
79
+ timeout += 6
80
+ end
81
+
82
+ end
83
+
84
+ def wait_for_disney_loader
85
+
86
+ timeout = 0
87
+
88
+ while browser.div(:class, 'ux-destination-services-detail-disney-pricebox-loading').visible? and timeout < 40
89
+ sleep 3
90
+ timeout += 3
91
+ end
92
+
93
+ end
94
+
95
+ def wait_for_universal_loader
96
+
97
+ timeout = 0
98
+
99
+ while browser.div(:class, 'ux-destination-services-detail-universal-pricebox-loading').visible? and timeout < 40
34
100
  sleep 3
35
101
  timeout += 3
36
102
  end
@@ -48,6 +114,17 @@ module Commons
48
114
 
49
115
  end
50
116
 
117
+ def wait_for_checkout
118
+
119
+ timeout = 0
120
+
121
+ while !browser.div(:class, 'ux-common-checkout-payment-method').present? and timeout < 60
122
+ sleep 3
123
+ timeout += 3
124
+ end
125
+
126
+ end
127
+
51
128
 
52
129
 
53
130
  end
@@ -40,7 +40,7 @@ module Navigation
40
40
  end
41
41
 
42
42
  def get_domain_by_country
43
- !DOMAIN.include?('decolar') ? (url = DOMAIN + '/actividades/') : (url = DOMAIN + '/atracoes-turisticas/')
43
+ !$DOMAIN.include?('decolar') ? (url = $DOMAIN + '/actividades/') : (url = $DOMAIN + '/atracoes-turisticas/')
44
44
  url
45
45
  end
46
46
 
@@ -54,7 +54,7 @@ module Navigation
54
54
  end
55
55
 
56
56
  def next_page?
57
- !browser.li(:class, 'next disabled').present?
57
+ browser.li(:class, 'next').present? and !browser.li(:class, 'next disabled').present?
58
58
  end
59
59
 
60
60
  def prev_page
@@ -4,6 +4,58 @@ require_relative './commons.rb'
4
4
 
5
5
  module Results
6
6
 
7
+ def get_results_by_tracking_id(trackingId, isModular = true)
8
+
9
+ ## Se selecciona el tipo de vista
10
+
11
+ cluster_view = browser.span(:class, 'ux-common-icon-cluster-view')
12
+
13
+ modular_view = browser.span(:class, 'ux-common-icon-modular-view')
14
+
15
+ isModular ? modular_view.click : cluster_view.click
16
+
17
+ categories = get_tour_category_texts.reverse
18
+
19
+ clusters = []
20
+
21
+ while clusters.empty? and !categories.empty?
22
+
23
+ category = categories.pop
24
+
25
+ filter_by_category(category)
26
+
27
+ wait_for_modal
28
+
29
+ wait_for_results
30
+
31
+ show_results_tracking_id
32
+
33
+ clusters = get_clusters_by_tracking_id(trackingId, isModular)
34
+
35
+ while clusters.empty? and next_page?
36
+
37
+ timeout = 0
38
+
39
+ next_page
40
+
41
+ wait_for_modal
42
+
43
+ wait_for_results
44
+
45
+ show_results_tracking_id
46
+
47
+ clusters = get_clusters_by_tracking_id(trackingId, isModular)
48
+
49
+ end
50
+
51
+ end
52
+
53
+ raise "No results found for the specified tracking ID ==> #{trackingId}" unless !clusters.empty?
54
+
55
+ clusters
56
+
57
+ end
58
+
7
59
 
8
60
  def get_results_by_provider_code(providerCode, isModular = true)
9
61
 
@@ -15,18 +67,17 @@ module Results
15
67
 
16
68
  isModular ? modular_view.click : cluster_view.click
17
69
 
18
- clusters = get_provider_results(providerCode, isModular)
70
+ categories = get_tour_category_texts.reverse
19
71
 
20
- while clusters.empty? and next_page?
72
+ clusters = []
21
73
 
22
- timeout = 0
74
+ while clusters.empty? and !categories.empty?
23
75
 
24
- next_page
76
+ category = categories.pop
25
77
 
26
- while browser.div(:class, 'modal').visible? and timeout < 40
27
- sleep 3
28
- timeout += 3
29
- end
78
+ filter_by_category(category)
79
+
80
+ wait_for_modal
30
81
 
31
82
  wait_for_results
32
83
 
@@ -34,8 +85,26 @@ module Results
34
85
 
35
86
  clusters = get_provider_results(providerCode, isModular)
36
87
 
88
+ while clusters.empty? and next_page?
89
+
90
+ timeout = 0
91
+
92
+ next_page
93
+
94
+ wait_for_modal
95
+
96
+ wait_for_results
97
+
98
+ show_results_tracking_id
99
+
100
+ clusters = get_provider_results(providerCode, isModular)
101
+
102
+ end
103
+
37
104
  end
38
105
 
106
+ raise 'No results found for the specified provider' unless !clusters.empty?
107
+
39
108
  clusters
40
109
 
41
110
  end
@@ -54,6 +123,20 @@ module Results
54
123
 
55
124
  end
56
125
 
126
+ def get_clusters_by_tracking_id(trackingId, isModular = true)
127
+
128
+ if isModular
129
+ clusters = browser.divs(:class, 'ux-destination-services-cluster-grid').to_a
130
+ clusters = clusters.select { | cluster | get_tracking_id(cluster).eql?(trackingId) }
131
+ else
132
+ clusters = browser.divs(:class, 'ux-destination-services-cluster').to_a
133
+ clusters = clusters.select { | cluster | get_tracking_id(cluster).eql?(trackingId) }
134
+ end
135
+
136
+ clusters
137
+
138
+ end
139
+
57
140
  def get_search_results(isModular = true)
58
141
 
59
142
  ## Se selecciona el tipo de vista
@@ -118,6 +201,34 @@ module Results
118
201
 
119
202
  end
120
203
 
204
+ def get_available_categories
205
+
206
+ available_categories = browser.div(:class, 'ux-common-filter-body ng-scope').lis.reject { | categories | !(categories.span(:class, 'ux-common-filter-total ng-binding').text.to_i > 0)}
207
+
208
+ available_categories
209
+
210
+ end
211
+
212
+ def get_tour_categories
213
+
214
+ tour_categories = get_available_categories.reject { | categories | categories.span(:class, 'ng-binding').text.eql?('Traslados') || categories.span(:class, 'ng-binding').text.eql?('Todas las actividades')}
215
+
216
+ tour_categories
217
+
218
+ end
219
+
220
+ def get_tour_category_texts
221
+
222
+ categories = []
223
+
224
+ get_tour_categories.each do | category |
225
+ categories << category.span(:class, 'ng-binding').text
226
+ end
227
+
228
+ categories
229
+
230
+ end
231
+
121
232
  def filter_by_higher_amount
122
233
 
123
234
  browser.div(:class, 'ux-common-filter-body ng-scope').lis[1].click
@@ -10,6 +10,20 @@ module Search
10
10
 
11
11
  end
12
12
 
13
+ def perform_search_for_tracking_id(trackingId)
14
+
15
+ destination = get_destination_from_tracking_id(trackingId)
16
+
17
+ url = get_domain_by_country + destination
18
+
19
+ browser.goto(url)
20
+
21
+ wait_for_results
22
+
23
+ browser.goto(url) unless browser.url.include?("#{url}")
24
+
25
+ end
26
+
13
27
 
14
28
  def perform_search(destination = nil, date = nil)
15
29