flights_gui_henry_tests 1.8.7
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.
- checksums.yaml +15 -0
- data/Gemfile +3 -0
- data/features/data/home-offers-config.csv +883 -0
- data/features/data/host.yml +72 -0
- data/features/data/miles.yml +216 -0
- data/features/data/search.yml +27 -0
- data/features/data/sites.yml +39 -0
- data/features/data/tag_microsoft.yml +68 -0
- data/features/step_definitions/checkout/agencia_steps.rb +6 -0
- data/features/step_definitions/checkout/chat_steps.rb +43 -0
- data/features/step_definitions/checkout/checkout_steps.rb +144 -0
- data/features/step_definitions/checkout/cupones_steps.rb +26 -0
- data/features/step_definitions/checkout/error_messages.rb +251 -0
- data/features/step_definitions/checkout/seguros_steps.rb +78 -0
- data/features/step_definitions/checkout/thanks_steps.rb +75 -0
- data/features/step_definitions/content/contents_steps.rb +140 -0
- data/features/step_definitions/desambiguation/disambiguation_airports_steps.rb +73 -0
- data/features/step_definitions/desambiguation/disambiguation_city_steps.rb +43 -0
- data/features/step_definitions/filter/filters_airlines.rb +38 -0
- data/features/step_definitions/filter/filters_airports_steps.rb +31 -0
- data/features/step_definitions/filter/filters_price_steps.rb +87 -0
- data/features/step_definitions/filter/filters_stops_steps.rb +44 -0
- data/features/step_definitions/filter/filters_time_steps.rb +143 -0
- data/features/step_definitions/filter/matrix_steps.rb +249 -0
- data/features/step_definitions/landing/landing_checkout_steps.rb +45 -0
- data/features/step_definitions/landing/landing_filters_steps.rb +17 -0
- data/features/step_definitions/landing/landing_home_alerts_steps.rb +21 -0
- data/features/step_definitions/landing/landing_home_steps.rb +82 -0
- data/features/step_definitions/landing/landing_long_tail.rb +58 -0
- data/features/step_definitions/landing/landing_negative_steps.rb +127 -0
- data/features/step_definitions/landing/landing_passenger_review_steps.rb +8 -0
- data/features/step_definitions/landing/landing_steps.rb +325 -0
- data/features/step_definitions/orders/orders.rb +67 -0
- data/features/step_definitions/others/advancedgui_steps.rb +28 -0
- data/features/step_definitions/others/advancednogui_steps.rb +34 -0
- data/features/step_definitions/others/anticipatedsearch_steps.rb +13 -0
- data/features/step_definitions/others/flights_tracker_steps.rb +73 -0
- data/features/step_definitions/others/generic_steps.rb +35 -0
- data/features/step_definitions/others/newsletter_steps.rb +50 -0
- data/features/step_definitions/others/one_day_search.rb +58 -0
- data/features/step_definitions/others/print_steps.rb +26 -0
- data/features/step_definitions/others/querystringparameters_steps.rb +6 -0
- data/features/step_definitions/others/recommendation_steps.rb +80 -0
- data/features/step_definitions/others/render_steps.rb +70 -0
- data/features/step_definitions/others/tag_steps.rb +157 -0
- data/features/step_definitions/others/upgrade_bussines_steps.rb +27 -0
- data/features/step_definitions/results/load_steps.rb +69 -0
- data/features/step_definitions/results/results_steps.rb +21 -0
- data/features/step_definitions/results/search_steps.rb +82 -0
- data/features/step_definitions/search/alerts_steps.rb +132 -0
- data/features/step_definitions/search/basefare_steps.rb +64 -0
- data/features/step_definitions/search/bestprices_steps.rb +70 -0
- data/features/step_definitions/search/cross_sell_row_hoteles.rb +78 -0
- data/features/step_definitions/search/cross_sell_steps.rb +15 -0
- data/features/step_definitions/search/delays_steps.rb +67 -0
- data/features/step_definitions/search/details_steps.rb +9 -0
- data/features/step_definitions/search/ecoflights_steps.rb +9 -0
- data/features/step_definitions/search/fenix_steps.rb +119 -0
- data/features/step_definitions/search/flight_gui_steps.rb +312 -0
- data/features/step_definitions/search/miles_step.rb +13 -0
- data/features/step_definitions/search/pagination_steps.rb +41 -0
- data/features/step_definitions/search/reviews_step.rb +56 -0
- data/features/step_definitions/search/search_no_gui_steps.rb +185 -0
- data/features/step_definitions/search/wish_list_steps.rb +123 -0
- data/features/support/env.rb +61 -0
- data/features/support/lib/clusters/data/datos_new.rb +33 -0
- data/features/support/lib/clusters/details/details_cluster.rb +30 -0
- data/features/support/lib/clusters/results/landing_cluster.rb +29 -0
- data/features/support/lib/clusters/results/render_cluster.rb +43 -0
- data/features/support/lib/clusters/results_cluster.rb +140 -0
- data/features/support/lib/clusters.rb +5 -0
- data/features/support/lib/helpers/browser.rb +212 -0
- data/features/support/lib/helpers/checkout.rb +31 -0
- data/features/support/lib/helpers/clusters.rb +234 -0
- data/features/support/lib/helpers/landing.rb +117 -0
- data/features/support/lib/helpers/render.rb +135 -0
- data/features/support/lib/helpers.rb +5 -0
- data/features/support/lib/price.rb +66 -0
- data/features/support/lib/services/fenix.rb +14 -0
- data/features/support/lib/services/landing.rb +18 -0
- data/features/support/lib/services/results.rb +62 -0
- data/features/support/lib/services.rb +4 -0
- data/features/support/matchers.rb +120 -0
- data/features/support/redefinitions.rb +42 -0
- data/features/tests/checkout/agency.feature +33 -0
- data/features/tests/checkout/button_cac.feature +52 -0
- data/features/tests/checkout/chat.feature +20 -0
- data/features/tests/checkout/cupones.feature +54 -0
- data/features/tests/checkout/error_messages.feature +64 -0
- data/features/tests/checkout/integration.feature +215 -0
- data/features/tests/checkout/low_cost.feature +55 -0
- data/features/tests/checkout/seguros.feature +37 -0
- data/features/tests/contents/costs.feature +29 -0
- data/features/tests/contents/rules.feature +58 -0
- data/features/tests/contents/webcheckin.feature +26 -0
- data/features/tests/desambiguation/airports.feature +89 -0
- data/features/tests/desambiguation/city.feature +86 -0
- data/features/tests/filters/filters.feature +160 -0
- data/features/tests/fixes/advancedgui.feature +171 -0
- data/features/tests/fixes/advancednogui.feature +60 -0
- data/features/tests/fixes/book_no_gui.feature +21 -0
- data/features/tests/fixes/cross_sell_row_hoteles.feature +70 -0
- data/features/tests/fixes/facebook.feature +31 -0
- data/features/tests/fixes/landing_home_alerts.feature +82 -0
- data/features/tests/fixes/matrix_stops.feature +104 -0
- data/features/tests/fixes/one_day_search.feature +63 -0
- data/features/tests/fixes/print.feature +87 -0
- data/features/tests/fixes/searches_no_gui.feature +85 -0
- data/features/tests/landing/landing_alerts.feature +93 -0
- data/features/tests/landing/landing_checkout.feature +286 -0
- data/features/tests/landing/landing_filters.feature +176 -0
- data/features/tests/landing/landing_home.feature +68 -0
- data/features/tests/landing/landing_integration.feature +153 -0
- data/features/tests/landing/landing_long_tail.feature +162 -0
- data/features/tests/landing/landing_matrix.feature +156 -0
- data/features/tests/landing/landing_negative.feature +157 -0
- data/features/tests/landing/landing_orders.feature +107 -0
- data/features/tests/landing/landing_pagination.feature +142 -0
- data/features/tests/landing/landing_passenger_review.feature +139 -0
- data/features/tests/landing/landing_positive.feature +155 -0
- data/features/tests/landing/landing_reviews.feature +139 -0
- data/features/tests/landing/landing_tags.feature +148 -0
- data/features/tests/matrix/matrix_airlines.feature +104 -0
- data/features/tests/matrix/matrix_fare_chart.feature +24 -0
- data/features/tests/matrix/matrix_price.feature +35 -0
- data/features/tests/others/alerts.feature +89 -0
- data/features/tests/others/anticipatedsearch.feature +82 -0
- data/features/tests/others/flights_tracker.feature +94 -0
- data/features/tests/others/newsletter.feature +131 -0
- data/features/tests/others/querystringparameters.feature +82 -0
- data/features/tests/others/recommendation.feature +170 -0
- data/features/tests/others/semaphore.feature +206 -0
- data/features/tests/others/upgrade_bussines.feature +100 -0
- data/features/tests/search/basefare.feature +88 -0
- data/features/tests/search/itineraries.feature +85 -0
- data/features/tests/search/orders.feature +100 -0
- data/features/tests/search/pagination.feature +70 -0
- data/features/tests/search/reviews.feature +84 -0
- data/features/tests/search/searches.feature +197 -0
- data/features/tests/search/wish_list.feature +102 -0
- data/flights_gui_henry_tests.gemspec +32 -0
- data/henry-context.yml +14733 -0
- metadata +324 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
Then /^Abro el popup de registro$/ do
|
|
3
|
+
BROWSER.div(:id,'nibbler-common-header').span(:class,'nibbler-common-icon-favourites').click
|
|
4
|
+
Watir::Wait.until(timeout=20){BROWSER.div(:id,'nibbler-selfservice-login-overlay').present?}
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Then /^Verifico links y textos del popup de registro$/ do
|
|
8
|
+
popup=BROWSER.div(:id,'nibbler-selfservice-login-overlay')
|
|
9
|
+
data_popup = Hpricot.parse(popup.html)
|
|
10
|
+
(data_popup/"div.nibbler-common-overlay-header").length.should equal(1)
|
|
11
|
+
(data_popup/"div.nibbler-common-overlay-body").length.should equal(1)
|
|
12
|
+
(data_popup/"div.nibbler-common-overlay-body div.nibbler-common-grid-row").length.should equal(2)
|
|
13
|
+
(data_popup/"div.nibbler-common-overlay-body div.nibbler-common-grid-row div.nibbler-common-grid-col6").length.should equal(2)
|
|
14
|
+
(data_popup/"div.nibbler-common-overlay-body div.nibbler-common-grid-row div.nibbler-common-grid-col6 a.nibbler-common-icon-facebook").length.should equal(1)
|
|
15
|
+
#(data_popup/"div.nibbler-common-overlay-body div.nibbler-common-grid-row div.nibbler-common-grid-col6 span.nibbler-common-icon-google").length.should equal(1)
|
|
16
|
+
(data_popup/"div.nibbler-common-overlay-body div.nibbler-common-grid-row div.nibbler-common-grid-col6 div.nibbler-selfservices-tabs li.nibbler-tab").length.should equal(2)
|
|
17
|
+
(data_popup/"div.nibbler-common-overlay-body div.nibbler-common-grid-row div#nibbler-selfservice-sign-in-despegar form#nibbler-login-form input#signin-email").length.should equal(1)
|
|
18
|
+
(data_popup/"div.nibbler-common-overlay-body div.nibbler-common-grid-row div#nibbler-selfservice-sign-in-despegar form#nibbler-login-form input#signin-pass").length.should equal(1)
|
|
19
|
+
(data_popup/"div.nibbler-common-overlay-body div.nibbler-common-grid-row div#nibbler-selfservice-sign-in-despegar button.nibbler-selfservice-pass-button").length.should equal(2)
|
|
20
|
+
(data_popup/"div.nibbler-common-overlay-body div.nibbler-common-grid-row div#nibbler-selfservice-sign-in-despegar form#nibbler-register-form input#signup-email").length.should equal(1)
|
|
21
|
+
(data_popup/"div.nibbler-common-overlay-body div.nibbler-common-grid-row div#nibbler-selfservice-sign-in-despegar form#nibbler-register-form input#signup-pass").length.should equal(1)
|
|
22
|
+
popup.li(:class=>'nibbler-tab',:index=>0).click
|
|
23
|
+
sleep(0.5)
|
|
24
|
+
popup.form(:id,'nibbler-login-form').should visible("formulario de login")
|
|
25
|
+
popup.li(:class=>'nibbler-tab',:index=>1).click
|
|
26
|
+
sleep(0.5)
|
|
27
|
+
popup.form(:id,'nibbler-register-form').should visible("formulario de registro")
|
|
28
|
+
popup.li(:class=>'nibbler-tab',:index=>0).click
|
|
29
|
+
sleep(0.5)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
Then /^Me logueo con usuario "(.*)" y pass "(.*)"$/ do |email,pass|
|
|
33
|
+
popup=BROWSER.div(:id,'nibbler-selfservice-login-overlay')
|
|
34
|
+
popup.text_field(:id,'signin-email').set(email)
|
|
35
|
+
popup.text_field(:id,'signin-pass').set(pass)
|
|
36
|
+
popup.button(:class,'nibbler-selfservice-pass-button').click
|
|
37
|
+
sleep(1)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Then /^Verifico que se muestre el error de logueo$/ do
|
|
41
|
+
BROWSER.div(:id,'nibbler-selfservice-login-overlay').span(:class,'nibbler-error-40101 nibbler-form-error').should visible("error de logueo")
|
|
42
|
+
BROWSER.div(:id,'nibbler-selfservice-login-overlay').span(:class,'nibbler-error-40101 nibbler-form-error').text.should match('Password is incorrect|A senha est.{1,2} incorreta|La contrase.{1,2}a es incorrecta')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
Then /^Verifico que se muestren en el header el usuario logueado$/ do
|
|
46
|
+
Watir::Wait.until(timeout=20){BROWSER.div(:id,'nibbler-common-header').div(:class,'fb-description').present?}
|
|
47
|
+
sleep(1)
|
|
48
|
+
BROWSER.div(:id,'nibbler-common-header').div(:class,'fb-description').strong(:class,'social-name').text.should equal("testvuelos@despegar.com")
|
|
49
|
+
BROWSER.div(:id,'nibbler-common-header').li(:class,'nibbler-common-header-favorites nibbler-user nibbler-common-header-favorites-has').should visible("corazon rojo en el header")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Then /^Abro la lista de deseos$/ do
|
|
53
|
+
BROWSER.div(:id,'nibbler-common-header').span(:class,'nibbler-common-icon-favourites').click
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
Then /^Verifico textos y que no se muestren opciones en la lista de deseos$/ do
|
|
57
|
+
BROWSER.div(:class,'nibbler-popup-wishlist nibbler-header-popup big').div(:class,'nibbler-common-last-searches nibbler-common-header-favorites-list').should visible("lista de elementos vacio")
|
|
58
|
+
BROWSER.div(:class,'nibbler-popup-wishlist nibbler-header-popup big').div(:class,'nibbler-common-last-searches nibbler-common-with').should_not visible("lista con deseos")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
Then /^Cierro la lista de deseos$/ do
|
|
62
|
+
BROWSER.div(:class,'nibbler-popup-wishlist nibbler-header-popup big').span(:class,'exit').click
|
|
63
|
+
sleep(1)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
Then /^Elijo un itinerario como deseado$/ do
|
|
67
|
+
BROWSER.div(:id,'clusters').div(:class,'cluster').radio(:id,'0-outbound-0').click if BROWSER.div(:id,'clusters').div(:class,'cluster').radio(:id,'0-outbound-0').present?
|
|
68
|
+
BROWSER.div(:id,'clusters').div(:class,'cluster').radio(:id,'0-inbound-0').click if BROWSER.div(:id,'clusters').div(:class,'cluster').radio(:id,'0-inbound-0').present?
|
|
69
|
+
BROWSER.div(:id,'clusters').div(:class,'cluster').div(:class,'icons').span(:class,'icon-wishlist ux-common-icon-favourites cluster-actions-icon').should visible("icono de deseado")
|
|
70
|
+
BROWSER.div(:id,'clusters').div(:class,'cluster').div(:class,'icons').span(:class,'icon-wishlist ux-common-icon-favourites cluster-actions-icon').click
|
|
71
|
+
cluster = ResultsCluster.new(@search.description,Hpricot.parse(BROWSER.div(:id,'clusters').div(:class,'cluster').html))
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
Then /^Verifico que el itinerario deseado quede marcado$/ do
|
|
75
|
+
sleep(2)
|
|
76
|
+
BROWSER.div(:id,'clusters').div(:class,'cluster').div(:class,'icons').span(:class,'icon-wishlist ux-common-icon-favourites cluster-actions-icon ux-common-icon-favourites-selected').should visible("icono de deseado seleccionado")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
Then /^Verifico que el itinerario deseado quede en la lista de deseos$/ do
|
|
80
|
+
BROWSER.div(:class,'nibbler-popup-wishlist nibbler-header-popup big').div(:class,'nibbler-common-last-searches nibbler-common-with').should visible("lista de deseos")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
Then /^Elijo el itinerario de la lista de deseos$/ do
|
|
84
|
+
@url = BROWSER.url
|
|
85
|
+
BROWSER.div(:class,'nibbler-popup-wishlist nibbler-header-popup big').div(:class,'nibbler-common-last-searches nibbler-common-with').click
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
Then /^Verifico que dirija correctamente a la pagina de resultados$/ do
|
|
89
|
+
@url.downcase.should match("#{BROWSER.url.gsub(/\?(.*)/,'').downcase}")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
Then /^Verifico que el itinerario deseado este marcado correctamente$/ do
|
|
93
|
+
BROWSER.div(:id,'clusters').div(:class,'cluster').radio(:id,'0-outbound-0').set?.should be_true if BROWSER.div(:id,'clusters').div(:class,'cluster').radio(:id,'0-outbound-0').present?
|
|
94
|
+
BROWSER.div(:id,'clusters').div(:class,'cluster').radio(:id,'0-inbound-0').set?.should be_true if BROWSER.div(:id,'clusters').div(:class,'cluster').radio(:id,'0-inbound-0').present?
|
|
95
|
+
BROWSER.div(:id,'clusters').div(:class,'cluster').div(:class,'icons').span(:class,'icon-wishlist ux-common-icon-favourites cluster-actions-icon ux-common-icon-favourites-selected').should visible("icono de deseado seleccionado")
|
|
96
|
+
BROWSER.div(:id,'clusters').div(:class,'cluster').span(:class,'ux-common-icon-favourites').should visible("icono de deseado en lista de precios")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
Then /^Elimino el itinerario de la lista de deseos$/ do
|
|
100
|
+
sleep(1)
|
|
101
|
+
BROWSER.execute_script("javascript:void($('.action-delete').click());")
|
|
102
|
+
sleep(2)
|
|
103
|
+
BROWSER.execute_script("javascript:void($('.action-delete').click());")
|
|
104
|
+
sleep(2)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
Then /^Limpio la lista de deseos$/ do
|
|
108
|
+
if BROWSER.div(:class,'nibbler-popup-wishlist nibbler-header-popup big').div(:class,'nibbler-common-last-searches nibbler-common-with').present?
|
|
109
|
+
sleep(1)
|
|
110
|
+
BROWSER.execute_script("javascript:void($('.action-delete').click());")
|
|
111
|
+
sleep(2)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
Then /^Me deslogueo como usuario$/ do
|
|
116
|
+
BROWSER.div(:id,'nibbler-common-header').link(:class,'social-logged').click if BROWSER.div(:id,'nibbler-common-header').link(:class,'social-logged').present?
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
Then /^Verifico que no se muestre en el header el usuario logueado$/ do
|
|
120
|
+
BROWSER.div(:id,'nibbler-common-header').span(:class,'nibbler-user-icon social-login').should visible("boton de logueo")
|
|
121
|
+
BROWSER.div(:id,'nibbler-common-header').div(:class,'fb-description').should_not visible("usuario logueado")
|
|
122
|
+
BROWSER.div(:id,'nibbler-common-header').li(:class,'nibbler-common-header-favorites nibbler-user nibbler-common-header-favorites-has').should_not visible("corazon rojo en el header")
|
|
123
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
require 'sixarm_ruby_unaccent'
|
|
4
|
+
require 'watir-webdriver'
|
|
5
|
+
require 'rspec'
|
|
6
|
+
require 'hpricot'
|
|
7
|
+
require 'httparty'
|
|
8
|
+
require 'henry/environment'
|
|
9
|
+
require 'sanitize'
|
|
10
|
+
require 'uri'
|
|
11
|
+
require 'mock_search'
|
|
12
|
+
|
|
13
|
+
$VERBOSE = nil
|
|
14
|
+
|
|
15
|
+
require_relative 'lib/price'
|
|
16
|
+
require_relative 'lib/clusters'
|
|
17
|
+
require_relative 'lib/helpers'
|
|
18
|
+
require_relative 'matchers'
|
|
19
|
+
|
|
20
|
+
SITES_FENIX = ["AR","BR","US","MX","EC","CR","CO","VE","PE","UY","CL","PA"]
|
|
21
|
+
|
|
22
|
+
def init_browser(type)
|
|
23
|
+
case type.upcase
|
|
24
|
+
when 'IE' then
|
|
25
|
+
:ie
|
|
26
|
+
when 'FIREFOX' then
|
|
27
|
+
:firefox
|
|
28
|
+
when 'CHROME' then
|
|
29
|
+
:chrome
|
|
30
|
+
else
|
|
31
|
+
:chrome
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def add_cookie(type)
|
|
36
|
+
case type.upcase
|
|
37
|
+
when 'RESULTS' then "results-f-gui=beta"
|
|
38
|
+
when 'CHECKOUT' then "chkf-app=beta"
|
|
39
|
+
when 'LANDING' then "landing-f-gui=beta"
|
|
40
|
+
when 'FSM' then "fsm-rest=beta"
|
|
41
|
+
else "landing-f-gui=beta|results-f-gui=beta|chkf-app=beta"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
begin
|
|
46
|
+
$henry_params = Henry::Environment.params
|
|
47
|
+
puts $henry_params
|
|
48
|
+
$ENV = $henry_params['env'] || "produccion"
|
|
49
|
+
browser = $henry_params['browser']
|
|
50
|
+
COOKIE = add_cookie($henry_params['product'])
|
|
51
|
+
rescue
|
|
52
|
+
$ENV = "produccion"
|
|
53
|
+
browser = "firefox"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
if browser
|
|
57
|
+
BROWSER = Watir::Browser.new init_browser(browser)
|
|
58
|
+
screen_width = BROWSER.execute_script("return screen.width;")
|
|
59
|
+
screen_height = BROWSER.execute_script("return screen.height;")
|
|
60
|
+
BROWSER.window.resize_to(screen_width, screen_height)
|
|
61
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class DatosNew
|
|
2
|
+
attr_accessor :origen, :destino, :fecha, :aerolinea, :escalas, :destino_iata, :origen_iata, :hou_sal_ida, :hou_lle_ida,:attributes, :duracion
|
|
3
|
+
|
|
4
|
+
def initialize (origen,destino,fecha, aerolinea, escalas, origen_iata=nil, destino_iata=nil,hou_sal_ida=nil,hou_lle_ida=nil,duracion=nil)
|
|
5
|
+
|
|
6
|
+
@duracion = duracion
|
|
7
|
+
@origen = origen
|
|
8
|
+
@destino = destino
|
|
9
|
+
@origen_iata = origen_iata
|
|
10
|
+
@destino_iata = destino_iata
|
|
11
|
+
@fecha = fecha.empty? ? nil : Date.parse_new_result(fecha)
|
|
12
|
+
@aerolinea = aerolinea
|
|
13
|
+
@escalas = escalas
|
|
14
|
+
@hou_sal_ida = hou_sal_ida
|
|
15
|
+
@hou_lle_ida = hou_lle_ida
|
|
16
|
+
@attributes = [:origen, :destino, :origen_iata, :destino_iata, :fecha, :aerolinea, :escalas, :hou_sal_ida, :hou_lle_ida, :duracion]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_s
|
|
20
|
+
return "Duracion: #{@duracion}, Origen: #{@origen}, Destino: #{@destino}, Iata: #{@origen_iata}-#{@destino_iata}, Fecha: #{@fecha}, Aerolinea: #{@aerolinea}, Hr salida: #{@hou_sal_ida}, Hr llegada: #{@hou_lle_ida}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
#se usa en el dinamico para comparar
|
|
24
|
+
def ==(other)
|
|
25
|
+
eq = true
|
|
26
|
+
self.attributes.each do |attrb|
|
|
27
|
+
if other
|
|
28
|
+
eq = false if self.send(attrb) != other.send(attrb)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
eq
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
class DetailsCluster
|
|
3
|
+
attr_accessor :tramos, :duracion
|
|
4
|
+
def initialize(p_html)
|
|
5
|
+
@duracion = (p_html/"div.popup-container div.popup-content span.total-duration").inner_text.strip.no_accents
|
|
6
|
+
@tramos = []
|
|
7
|
+
(p_html/"div.popup-container div.popup-content div.detail").each do |div|
|
|
8
|
+
tramo = Hash.new
|
|
9
|
+
tramo['clase'] = (div/"div.segment span.class").first.inner_text.strip.no_accents
|
|
10
|
+
tramo['ciudad_origen'] = (div/"li.departure span.location span.data").first.inner_text.strip.no_accents
|
|
11
|
+
tramo['fecha_origen'] = Date.parse_new_details((div/"li.departure span.date span.day").first.inner_text.strip.no_accents)
|
|
12
|
+
tramo['hora_origen'] = Time.parse((div/"li.departure span.date span.hour").first.inner_text.strip.no_accents)
|
|
13
|
+
tramo['ciudad_destino'] = (div/"li.arrival span.location span.data").last.inner_text.strip.no_accents
|
|
14
|
+
tramo['hora_destino'] = Time.parse((div/"li.arrival span.date span.hour").last.inner_text.strip.no_accents)
|
|
15
|
+
@tramos << tramo
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_s
|
|
20
|
+
text = String.new
|
|
21
|
+
@tramos.each_with_index do |tramo,i|
|
|
22
|
+
text << "[Tramo #{i}: "
|
|
23
|
+
tramo.each_pair do |key,value|
|
|
24
|
+
text << "#{key}:#{value} - "
|
|
25
|
+
end
|
|
26
|
+
text << "]"
|
|
27
|
+
end
|
|
28
|
+
return text
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
class LandingCluster < ResultsCluster
|
|
3
|
+
|
|
4
|
+
def load_prices(p_html)
|
|
5
|
+
|
|
6
|
+
@tarifas = Hash.new
|
|
7
|
+
@tarifas['tarifa_adulto'] = Price.new((p_html/"span.price-currency span.currency").first.inner_text.strip + " " + (p_html/"span.price-currency span.amount").first.inner_text.strip)
|
|
8
|
+
@tarifas['tarifa_adulto_dolar'] = Price.new((p_html/"span.price-currency span.currency").last.inner_text.strip + " " + (p_html/"span.price-currency span.amount").last.inner_text.strip)
|
|
9
|
+
@tarifas['adt'] = (p_html/"ul.fare-detail//li").empty? ? Price.new("$ 0",true) : Price.new(((p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /adulto/}.first/"span[@class='price-currency ARS']").inner_text.strip)
|
|
10
|
+
|
|
11
|
+
adt = (p_html/"li").select{|li| li.inner_text.no_accents.downcase =~ /adulto/}.first
|
|
12
|
+
@tarifas['adt'] = adt ? Price.new((adt/"span.currency").first.inner_text.strip + " " + (adt/"span.amount").first.inner_text.strip) : Price.new("$ 0",true)
|
|
13
|
+
|
|
14
|
+
tasas = (p_html/"li.taxes-price").empty? ? (p_html/"li[@class='taxDetail.OTHER-price']").first : (p_html/"li.taxes-price").first
|
|
15
|
+
@tarifas['tasas'] = tasas ? Price.new((tasas/"span.currency").first.inner_text.strip + " " + (tasas/"span.amount").first.inner_text.strip,true) : Price.new("$ 0",true)
|
|
16
|
+
|
|
17
|
+
cargos = (p_html/"li.charges-price").first
|
|
18
|
+
@tarifas['cargos'] = cargos ? Price.new((cargos/"span.currency").first.inner_text.strip + " " + (cargos/"span.amount").first.inner_text.strip,true) : Price.new("$ 0",true)
|
|
19
|
+
|
|
20
|
+
afip = (p_html/"li[@class='taxDetail.ZK-price']").first
|
|
21
|
+
@tarifas['afip'] = afip ? Price.new((afip/"span.currency").first.inner_text.strip + " " + (afip/"span.amount").first.inner_text.strip,true) : Price.new("$ 0",true)
|
|
22
|
+
|
|
23
|
+
@tarifas['encargos'] = Price.new("$ 0",true)
|
|
24
|
+
|
|
25
|
+
campo = (p_html/"li").empty? ? "total" : "fare"
|
|
26
|
+
@tarifas['total'] = (p_html/"li.#{campo}-price span.currency").empty? ? Price.new("$ 0",true) : Price.new((p_html/"li.#{campo}-price span.currency").first.inner_text.strip + " " + (p_html/"li.#{campo}-price span.amount").first.inner_text.strip)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
class RenderCluster < ResultsCluster
|
|
2
|
+
def load_prices(p_html)
|
|
3
|
+
|
|
4
|
+
@tarifas = Hash.new
|
|
5
|
+
|
|
6
|
+
if !(p_html/"div.fare-difference").empty?
|
|
7
|
+
con_diferencia(p_html)
|
|
8
|
+
else
|
|
9
|
+
sin_diferencia(p_html)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def con_diferencia(p_html)
|
|
15
|
+
if (p_html/"span.difference-description").inner_text.strip.match(/Sin costo adicional|Sem costo adicional|Sem custo adicional/)
|
|
16
|
+
@tarifas['adicional'] = Price.new("$ 0",true)
|
|
17
|
+
else
|
|
18
|
+
@tarifas['adicional'] = Price.new((p_html/"span.difference-price/span.currency").inner_text.strip + " " + (p_html/"span.difference-price/span.amount").inner_text.strip,true)
|
|
19
|
+
@tarifas['adicional'].set_valor(@tarifas['adicional'].valor * ((p_html/"span.difference-price/span.difference").inner_text.match(/\+/) ? 1 : -1))
|
|
20
|
+
end
|
|
21
|
+
@tarifas['tarifa_adulto'] = Price.new("$ 0",true)
|
|
22
|
+
@tarifas['tarifa_adulto_dolar'] = Price.new("$ 0",true)
|
|
23
|
+
@tarifas['adt'] = Price.new("$ 0",true)
|
|
24
|
+
@tarifas['cnn'] = Price.new("$ 0",true)
|
|
25
|
+
@tarifas['inf'] = Price.new("$ 0",true)
|
|
26
|
+
@tarifas['tasas'] = Price.new("$ 0",true)
|
|
27
|
+
@tarifas['cargos'] = Price.new("$ 0",true)
|
|
28
|
+
@tarifas['encargos'] = Price.new("$ 0",true)
|
|
29
|
+
@tarifas['total'] = (p_html/"div.fare-total/span.total-price").empty? ? Price.new("$ 0",true) : Price.new((p_html/"div.fare-total/span.total-price").first.inner_text.strip)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def sin_diferencia(p_html)
|
|
33
|
+
@tarifas['tarifa_adulto'] = Price.new((p_html/"span.fare/span.price-currency").first.inner_text.strip)
|
|
34
|
+
@tarifas['tarifa_adulto_dolar'] = Price.new((p_html/"span.fare/span.price-currency").last.inner_text.strip)
|
|
35
|
+
@tarifas['adt'] = (p_html/"ul.fare-detail//li").empty? ? Price.new("$ 0",true) : Price.new(((p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /adulto/}.first/"span[@class='price-currency ARS']").inner_text.strip)
|
|
36
|
+
@tarifas['cnn'] = (p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /nino/}.first ? Price.new(((p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /nino/}.first/"span[@class='price-currency ARS']").inner_text.strip,true) : Price.new("$ 0",true)
|
|
37
|
+
@tarifas['inf'] = (p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /bebe/}.first ? Price.new(((p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /bebe/}.first/"span[@class='price-currency ARS']").inner_text.strip,true) : Price.new("$ 0",true)
|
|
38
|
+
@tarifas['tasas'] = (p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /tasas/}.first ? Price.new(((p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /tasas/}.first/"span[@class='price-currency ARS']").inner_text.strip,true) : Price.new("$ 0",true)
|
|
39
|
+
@tarifas['cargos'] = (p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /cargos/}.first ? Price.new(((p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /cargos/}.first/"span[@class='price-currency ARS']").inner_text.strip,true) : Price.new("$ 0",true)
|
|
40
|
+
@tarifas['encargos'] = Price.new("$ 0",true)
|
|
41
|
+
@tarifas['total'] = (p_html/"ul.fare-detail/li.total-price//span.price-currency").empty? ? Price.new("$ 0",true) : Price.new((p_html/"ul.fare-detail/li.total-price//span.price-currency").first.inner_text.strip)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
require_relative 'data/datos_new'
|
|
2
|
+
class ResultsCluster
|
|
3
|
+
|
|
4
|
+
attr_accessor :ida, :vuelta, :tarifas, :idas, :vueltas
|
|
5
|
+
|
|
6
|
+
def initialize(itinerario,html,page = 0)
|
|
7
|
+
eval "#{itinerario.downcase}(html)"
|
|
8
|
+
self.load_prices((html/"div.fare-container"))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def roundtrip(html)
|
|
12
|
+
self.load_data_from((html/"div.itineraries div[@class='sub-cluster outbound']"))
|
|
13
|
+
self.load_data_to((html/"div.itineraries div[@class='sub-cluster inbound']"))
|
|
14
|
+
end
|
|
15
|
+
def oneway(html)
|
|
16
|
+
self.load_data_from((html/"div.itineraries//div[@class='sub-cluster outbound']"))
|
|
17
|
+
@nro_vuelo_vuelta = -1
|
|
18
|
+
end
|
|
19
|
+
def multipledestinations(html)
|
|
20
|
+
self.load_data_from((html/"div.itineraries//div[@class='sub-cluster multiple']"))
|
|
21
|
+
self.load_data_to((html/"div.itineraries//div[@class='sub-cluster multiple']").last)
|
|
22
|
+
end
|
|
23
|
+
def load_data_from(div_datos)
|
|
24
|
+
@idas = Array.new
|
|
25
|
+
(div_datos/"li.itinerary").each do |div_datos_ida|
|
|
26
|
+
duracion = (div_datos_ida/"li.time").inner_text.strip
|
|
27
|
+
origen = (div_datos/"li.city-departure").first.inner_text.gsub(/,/,'').strip.no_accents
|
|
28
|
+
destino= (div_datos/"li.city-arrival").first.inner_text.gsub(/,/,'').strip.no_accents
|
|
29
|
+
origen_iata = (div_datos/"a").empty? ? (div_datos/"div.fechayDestinos/span.aeropuertoSalida").inner_text.match(/(.+)\((.+)\)(.+)/)[2].strip : (div_datos/"a")[0].inner_text.strip
|
|
30
|
+
destino_iata = (div_datos/"a").empty? ? (div_datos/"div.fechayDestinos/span.aeropuertoLlegada").inner_text.match(/(.+)\((.+)\)/)[2].strip : (div_datos/"a")[1].inner_text.strip
|
|
31
|
+
fecha = (div_datos_ida/"li.date").empty? ? (div_datos/"li.date").first.inner_text.strip.no_accents : (div_datos_ida/"li.date").first.inner_text.strip.no_accents
|
|
32
|
+
escala = (div_datos_ida/"li.stops/a").inner_text.strip.empty? ? "Sin escalas" : (div_datos_ida/"li.stops/a").inner_text.to_i
|
|
33
|
+
aerolinea = Array.new
|
|
34
|
+
i = 0
|
|
35
|
+
(div_datos_ida/"li.airlinesShort//img").each do |aer|
|
|
36
|
+
aerolinea << aer.attributes['src'].match(/(..).png/)[1].upcase
|
|
37
|
+
i = i + 1
|
|
38
|
+
end
|
|
39
|
+
(div_datos_ida/"li.airlines//img").each do |aer|
|
|
40
|
+
aerolinea << aer.attributes['src'].match(/(..).png/)[1].upcase
|
|
41
|
+
i = i + 1
|
|
42
|
+
end
|
|
43
|
+
hou_sal_ida = Time.parse((div_datos_ida/"li.leave/strong").inner_text.strip)
|
|
44
|
+
hou_lle_ida = Time.parse((div_datos_ida/"li.arrive/strong").inner_text.strip)
|
|
45
|
+
@idas << DatosNew.new(origen,destino,fecha, aerolinea, escala_to_i(escala),origen_iata,destino_iata,hou_sal_ida,hou_lle_ida,duracion)
|
|
46
|
+
end
|
|
47
|
+
@nro_vuelo_ida = 0
|
|
48
|
+
@ida = @idas[@nro_vuelo_ida]
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
def load_data_to(div_datos)
|
|
52
|
+
|
|
53
|
+
@vueltas = Array.new
|
|
54
|
+
(div_datos/"li.itinerary").each do |div_datos_vuelta|
|
|
55
|
+
duracion = (div_datos_vuelta/"li.time").inner_text.strip
|
|
56
|
+
origen = (div_datos/"li.city-departure").first.inner_text.gsub(/,/,'').strip.no_accents
|
|
57
|
+
destino= (div_datos/"li.city-arrival").first.inner_text.gsub(/,/,'').strip.no_accents
|
|
58
|
+
origen_iata = (div_datos/"a").empty? ? (div_datos/"div.fechayDestinos/span.aeropuertoSalida").inner_text.match(/(.+)\((.+)\)(.+)/)[2].strip : (div_datos/"a")[0].inner_text.strip
|
|
59
|
+
destino_iata = (div_datos/"a").empty? ? (div_datos/"div.fechayDestinos/span.aeropuertoLlegada").inner_text.match(/(.+)\((.+)\)/)[2].strip : (div_datos/"a")[1].inner_text.strip
|
|
60
|
+
fecha = (div_datos_vuelta/"li.date").empty? ? (div_datos/"li.date").last.inner_text.strip.no_accents : (div_datos_vuelta/"li.date").last.inner_text.strip.no_accents
|
|
61
|
+
escala = (div_datos_vuelta/"li.stops/a").inner_text.strip.empty? ? "Sin escalas" : (div_datos_vuelta/"li.stops/a").inner_text.to_i
|
|
62
|
+
aerolinea = Array.new
|
|
63
|
+
i = 0
|
|
64
|
+
(div_datos_vuelta/"li.airlinesShort//img").each do |aer|
|
|
65
|
+
aerolinea << aer.attributes['src'].match(/(..).png/)[1].upcase
|
|
66
|
+
i = i + 1
|
|
67
|
+
end
|
|
68
|
+
(div_datos_vuelta/"li.airlines//img").each do |aer|
|
|
69
|
+
aerolinea << aer.attributes['src'].match(/(..).png/)[1].upcase
|
|
70
|
+
i = i + 1
|
|
71
|
+
end
|
|
72
|
+
hou_sal_ida = Time.parse((div_datos_vuelta/"li.leave/strong").inner_text.strip)
|
|
73
|
+
hou_lle_ida = Time.parse((div_datos_vuelta/"li.arrive/strong").inner_text.strip)
|
|
74
|
+
@vueltas << DatosNew.new(origen,destino,fecha, aerolinea, escala_to_i(escala),origen_iata,destino_iata,hou_sal_ida,hou_lle_ida,duracion)
|
|
75
|
+
end
|
|
76
|
+
@nro_vuelo_vuelta = 0
|
|
77
|
+
@vuelta = @vueltas[@nro_vuelo_vuelta]
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def load_prices(p_html)
|
|
82
|
+
|
|
83
|
+
@tarifas = Hash.new
|
|
84
|
+
@tarifas['tarifa_adulto_dolar'] = Price.new((p_html/"span.price-currency span.currency").last.inner_text.strip + " " + (p_html/"span.price-currency span.amount").last.inner_text.strip)
|
|
85
|
+
if (p_html/"span[@class='price-currency #{currency($SITE)} '] span.currency").first
|
|
86
|
+
@tarifas['tarifa_adulto'] = Price.new((p_html/"span[@class='price-currency #{currency($SITE)} '] span.currency").first.inner_text.strip + " " + (p_html/"span[@class='price-currency #{currency($SITE)} '] span.amount").first.inner_text.strip)
|
|
87
|
+
else
|
|
88
|
+
@tarifas['tarifa_adulto'] = @tarifas['tarifa_adulto_dolar']
|
|
89
|
+
end
|
|
90
|
+
@tarifas['adt'] = (p_html/"ul.fare-detail//li").empty? ? Price.new("$ 0",true) : Price.new(((p_html/"ul.fare-detail//li").select{|li| li.inner_text.no_accents.downcase =~ /adulto/}.first/"span[@class='price-currency ARS']").inner_text.strip)
|
|
91
|
+
|
|
92
|
+
adt = (p_html/"li").select{|li| li.inner_text.no_accents.downcase =~ /adulto/}.first
|
|
93
|
+
@tarifas['adt'] = adt ? Price.new((adt/"span.currency").first.inner_text.strip + " " + (adt/"span.amount").first.inner_text.strip) : Price.new("$ 0",true)
|
|
94
|
+
|
|
95
|
+
tasas = (p_html/"li.taxes-price").empty? ? (p_html/"li[@class='taxDetail.OTHER-price']").first : (p_html/"li.taxes-price").first
|
|
96
|
+
@tarifas['tasas'] = tasas ? Price.new((tasas/"span.currency").first.inner_text.strip + " " + (tasas/"span.amount").first.inner_text.strip,true) : Price.new("$ 0",true)
|
|
97
|
+
|
|
98
|
+
cargos = (p_html/"li.charges-price").first
|
|
99
|
+
@tarifas['cargos'] = cargos ? Price.new((cargos/"span.currency").first.inner_text.strip + " " + (cargos/"span.amount").first.inner_text.strip,true) : Price.new("$ 0",true)
|
|
100
|
+
|
|
101
|
+
afip = (p_html/"li[@class='taxDetail.ZK-price']").first
|
|
102
|
+
@tarifas['afip'] = afip ? Price.new((afip/"span.currency").first.inner_text.strip + " " + (afip/"span.amount").first.inner_text.strip,true) : Price.new("$ 0",true)
|
|
103
|
+
|
|
104
|
+
@tarifas['encargos'] = Price.new("$ 0",true)
|
|
105
|
+
|
|
106
|
+
campo = (p_html/"li").empty? ? "total" : "fare"
|
|
107
|
+
@tarifas['total'] = (p_html/"li.#{campo}-price span.currency").empty? ? Price.new("$ 0",true) : Price.new((p_html/"li.#{campo}-price span.currency").first.inner_text.strip + " " + (p_html/"li.#{campo}-price span.amount").first.inner_text.strip)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def validarSumaDesgloce(linea = "total|tarifa_adulto")
|
|
111
|
+
|
|
112
|
+
sumaTarifas = 0
|
|
113
|
+
@tarifas.each_pair do |key,tarifa|
|
|
114
|
+
if key !~ /#{linea}/
|
|
115
|
+
sumaTarifas += tarifa.valor
|
|
116
|
+
end
|
|
117
|
+
if @tarifas['total'] and (tarifa.valor > @tarifas['total'].valor) and (linea !~ /tarifa_adulto/)
|
|
118
|
+
true.should be_true
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
if @tarifas['total'] and ((sumaTarifas.to_i - @tarifas['total'].valor.to_i) > 3)
|
|
123
|
+
true.should be_true
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
end
|
|
127
|
+
def validarEcuacionTarifasPorCantidadDePasajeros(cant)
|
|
128
|
+
unless @tarifas['adt'].valor.zero?
|
|
129
|
+
(@tarifas['adt'].valor == @tarifas['tarifa_adulto'].valor * cant).should be_true
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
def validarResolucionAFIP
|
|
133
|
+
(@tarifas['total'] * 20 / 100).truncate + 1 == @tarifas['afip']
|
|
134
|
+
end
|
|
135
|
+
def total_escalas()
|
|
136
|
+
vueltas = @vueltas ? @vueltas.collect{|vuelta| vuelta.escalas} : []
|
|
137
|
+
(vueltas + @idas.collect{|vuelta| vuelta.escalas}).sort
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end
|