flights_gui_henry_tests_ds 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/features/data/home-offers-config.csv +883 -0
- data/features/data/host.yml +78 -0
- data/features/data/miles.yml +216 -0
- data/features/data/search.yml +27 -0
- data/features/data/sites.yml +49 -0
- data/features/data/sites.yml.orig +54 -0
- data/features/data/tag_microsoft.yml +68 -0
- data/features/step_definitions/checkout/agencia_steps.rb +6 -0
- data/features/step_definitions/checkout/cash_payment_steps.rb +70 -0
- data/features/step_definitions/checkout/chat_steps.rb +57 -0
- data/features/step_definitions/checkout/checkout_steps.rb +265 -0
- data/features/step_definitions/checkout/cupones_steps.rb +36 -0
- data/features/step_definitions/checkout/error_messages.rb +291 -0
- data/features/step_definitions/checkout/fast_checkout.rb +55 -0
- data/features/step_definitions/checkout/price_jump_steps.rb +70 -0
- data/features/step_definitions/checkout/seguros_steps.rb +79 -0
- data/features/step_definitions/checkout/thanks_steps.rb +81 -0
- data/features/step_definitions/content/contents_steps.rb +140 -0
- data/features/step_definitions/desambiguation/disambiguation_airports_steps.rb +82 -0
- data/features/step_definitions/desambiguation/disambiguation_city_steps.rb +53 -0
- data/features/step_definitions/filter/filters_airlines.rb +37 -0
- data/features/step_definitions/filter/filters_airports_steps.rb +31 -0
- data/features/step_definitions/filter/filters_price_steps.rb +91 -0
- data/features/step_definitions/filter/filters_stops_steps.rb +44 -0
- data/features/step_definitions/filter/filters_time_steps.rb +146 -0
- data/features/step_definitions/filter/matrix_steps.rb +276 -0
- data/features/step_definitions/landing/landing_checkout_steps.rb +49 -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 +128 -0
- data/features/step_definitions/landing/landing_passenger_review_steps.rb +8 -0
- data/features/step_definitions/landing/landing_steps.rb +348 -0
- data/features/step_definitions/orders/orders.rb +83 -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/cookies_steps.rb +40 -0
- data/features/step_definitions/others/flights_tracker_steps.rb +74 -0
- data/features/step_definitions/others/generic_steps.rb +33 -0
- data/features/step_definitions/others/newsletter_steps.rb +29 -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 +78 -0
- data/features/step_definitions/others/render_steps.rb +70 -0
- data/features/step_definitions/others/tag_steps.rb +164 -0
- data/features/step_definitions/others/upgrade_bussines_steps.rb +27 -0
- data/features/step_definitions/results/devtools_steps.rb +10 -0
- data/features/step_definitions/results/itineraries_steps.rb +43 -0
- data/features/step_definitions/results/load_steps.rb +73 -0
- data/features/step_definitions/results/results_steps.rb +79 -0
- data/features/step_definitions/results/search_steps.rb +115 -0
- data/features/step_definitions/search/alerts_steps.rb +132 -0
- data/features/step_definitions/search/basefare_steps.rb +88 -0
- data/features/step_definitions/search/bestprices_steps.rb +70 -0
- data/features/step_definitions/search/cross_sell_row_hoteles.rb +52 -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/errors_steps.rb +24 -0
- data/features/step_definitions/search/fenix_steps.rb +99 -0
- data/features/step_definitions/search/flight_gui_steps.rb +376 -0
- data/features/step_definitions/search/miles_step.rb +13 -0
- data/features/step_definitions/search/pagination_steps.rb +29 -0
- data/features/step_definitions/search/reviews_step.rb +58 -0
- data/features/step_definitions/search/search_no_gui_steps.rb +185 -0
- data/features/step_definitions/search/wish_list_steps.rb +128 -0
- data/features/support/env.rb +86 -0
- data/features/support/lib/clusters.rb +6 -0
- data/features/support/lib/clusters/checkout_cluster.rb +111 -0
- data/features/support/lib/clusters/data/data.rb +33 -0
- data/features/support/lib/clusters/details/details_cluster.rb +36 -0
- data/features/support/lib/clusters/results/landing_cluster.rb +87 -0
- data/features/support/lib/clusters/results/render_cluster.rb +86 -0
- data/features/support/lib/clusters/results_cluster.rb +168 -0
- data/features/support/lib/helpers.rb +5 -0
- data/features/support/lib/helpers/browser.rb +235 -0
- data/features/support/lib/helpers/checkout.rb +29 -0
- data/features/support/lib/helpers/clusters.rb +166 -0
- data/features/support/lib/helpers/landing.rb +121 -0
- data/features/support/lib/helpers/render.rb +135 -0
- data/features/support/lib/price.rb +66 -0
- data/features/support/lib/process_manager.rb +104 -0
- data/features/support/lib/services.rb +4 -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/matchers.rb +120 -0
- data/features/support/redefinitions.rb +42 -0
- data/features/tests/checkout/agency.feature +27 -0
- data/features/tests/checkout/button_cac.feature +53 -0
- data/features/tests/checkout/cash_payment.feature +50 -0
- data/features/tests/checkout/compras_duplicadas.feature +95 -0
- data/features/tests/checkout/cupones.feature +34 -0
- data/features/tests/checkout/error_messages.feature +80 -0
- data/features/tests/checkout/fast_checkout.feature +82 -0
- data/features/tests/checkout/integration.feature +235 -0
- data/features/tests/checkout/low_cost.feature +62 -0
- data/features/tests/checkout/online_payment.feature +50 -0
- data/features/tests/checkout/price_jump.feature +103 -0
- data/features/tests/checkout/providers.feature +76 -0
- data/features/tests/checkout/seguros.feature +42 -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/airports_landing.feature +88 -0
- data/features/tests/desambiguation/city.feature +86 -0
- data/features/tests/filters/filters.feature +113 -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_checkout.feature +286 -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/fixes/upgrade_bussines.feature +100 -0
- data/features/tests/landing/landing_alerts.feature +93 -0
- data/features/tests/landing/landing_filters.feature +171 -0
- data/features/tests/landing/landing_home.feature +68 -0
- data/features/tests/landing/landing_integration.feature +149 -0
- data/features/tests/landing/landing_long_tail.feature +169 -0
- data/features/tests/landing/landing_matrix.feature +152 -0
- data/features/tests/landing/landing_negative.feature +151 -0
- data/features/tests/landing/landing_orders.feature +79 -0
- data/features/tests/landing/landing_pagination.feature +141 -0
- data/features/tests/landing/landing_passenger_review.feature +135 -0
- data/features/tests/landing/landing_positive.feature +151 -0
- data/features/tests/landing/landing_reviews.feature +135 -0
- data/features/tests/landing/landing_sort.feature +140 -0
- data/features/tests/landing/landing_tags.feature +142 -0
- data/features/tests/matrix/matrix_airlines.feature +80 -0
- data/features/tests/matrix/matrix_fare_chart.feature +40 -0
- data/features/tests/matrix/matrix_price.feature +40 -0
- data/features/tests/others/alerts.feature +89 -0
- data/features/tests/others/anticipatedsearch.feature +82 -0
- data/features/tests/others/chat.feature +23 -0
- data/features/tests/others/flights_tracker.feature +94 -0
- data/features/tests/others/newsletter.feature +118 -0
- data/features/tests/others/querystringparameters.feature +82 -0
- data/features/tests/others/recommendation.feature +107 -0
- data/features/tests/others/semaphore.feature +206 -0
- data/features/tests/search/basefare.feature +89 -0
- data/features/tests/search/errors.feature +198 -0
- data/features/tests/search/itineraries.feature +92 -0
- data/features/tests/search/orders.feature +88 -0
- data/features/tests/search/pagination.feature +73 -0
- data/features/tests/search/reviews.feature +83 -0
- data/features/tests/search/searches.feature +214 -0
- data/features/tests/search/wish_list.feature +58 -0
- data/flights_gui_henry_tests.gemspec +32 -0
- data/henry-context.yml +17262 -0
- metadata +382 -0
@@ -0,0 +1,135 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
#validaciones js and css de shop flights
|
3
|
+
def get_render(url,type)
|
4
|
+
begin
|
5
|
+
get = HTTParty.get("#{url}#{type}")
|
6
|
+
rescue
|
7
|
+
true.should be_true
|
8
|
+
end
|
9
|
+
return get
|
10
|
+
end
|
11
|
+
def validate_render(url,type)
|
12
|
+
data = get_render(url,type)
|
13
|
+
if data.code == 200
|
14
|
+
respond = Hpricot.parse(data.body)
|
15
|
+
respond.inner_text.should_not match("FreeMarker template error!")
|
16
|
+
else
|
17
|
+
true.should be_true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
def escala_to_i(escala)
|
21
|
+
return 0 if escala.to_s =~ /(solo vuelo directo)|(Sin escalas)|(Sem escalas)|(Soamente v.o directo)|(Vuelo Directo)/i
|
22
|
+
return escala.to_s.gsub(/\D/,'').to_i
|
23
|
+
end
|
24
|
+
def validar_fechas(ticket,search)
|
25
|
+
if search.type.downcase !~ /multiple/
|
26
|
+
(ticket.ida.fecha == search.date_from).should be_true
|
27
|
+
if search.type.downcase =~ /roundtrip/
|
28
|
+
(ticket.vuelta.fecha == search.date_to).should be_true
|
29
|
+
end
|
30
|
+
else
|
31
|
+
(search.dates.split(',').include?(ticket.ida.fecha.to_s)).should be_true
|
32
|
+
(search.dates.split(',').include?(ticket.vuelta.fecha.to_s)).should be_true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
#redefinicion del metodo que valida las ciudades en cada cluster
|
36
|
+
#se agrega la validacion del nombre de las ciudades origen/destino
|
37
|
+
def validar_destinos(ticket,search,html)
|
38
|
+
if search.type !~ /multipledestinations/
|
39
|
+
((!search.from_city.airports.include?(ticket.ida.origen_iata))and(!search.to_city.airports.include?(ticket.ida.destino_iata))).should_not be_true
|
40
|
+
if search.type == 'roundtrip'
|
41
|
+
((!search.to_city.airports.include?(ticket.vuelta.origen_iata))and(!search.from_city.airports.include?(ticket.vuelta.destino_iata))).should_not be_true
|
42
|
+
end
|
43
|
+
else
|
44
|
+
i = 0
|
45
|
+
(html/"div.sub-cluster.multiple").each do |tramo|
|
46
|
+
#(tramo/"li.city-departure").inner_text.gsub(/,/,'').strip.downcase.no_accents.downcase.should match("#{@search.from_cities[i].name}")
|
47
|
+
i += 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
#validar que el boton de seleccionar sea correcto
|
52
|
+
def validar_button(doc)
|
53
|
+
((doc/"a[@class='buy btn-buy flights-button']/span").empty? or !(doc/"a[@class='buy btn-buy flights-button']/span").inner_text.strip.downcase.match(/seleccionar|selecionar/)).should_not be_true
|
54
|
+
end
|
55
|
+
def other_page(page)
|
56
|
+
if BROWSER.li(:class => "page", :index => page).present? or BROWSER.li(:class,'next enabled').present?
|
57
|
+
if BROWSER.li(:class,'next enabled').present?
|
58
|
+
BROWSER.li(:class,'next enabled').click
|
59
|
+
else
|
60
|
+
BROWSER.li(:class => "page", :index => page).click
|
61
|
+
end
|
62
|
+
wait_action()
|
63
|
+
return nil
|
64
|
+
else
|
65
|
+
BROWSER.li(:class => "page", :index => 0).click if BROWSER.li(:class => "page", :index => 0).present?
|
66
|
+
wait_action()
|
67
|
+
return true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
def wait_action()
|
71
|
+
Watir::Wait.until(timeout = 120){(!BROWSER.div(:class => "results-update").present?)}
|
72
|
+
end
|
73
|
+
#validar que se muestren correctamente los precios si la sesion expiro
|
74
|
+
def validate_prices_session_expired(ticket)
|
75
|
+
!ticket.tarifas['adicional'].nil?
|
76
|
+
end
|
77
|
+
#validar que se muestren correctamente los precios si la sesion no expiro
|
78
|
+
def validate_prices_without_session_expired(ticket)
|
79
|
+
ticket.tarifas['adicional'].nil?
|
80
|
+
end
|
81
|
+
#validaciones del popup de mas detalles
|
82
|
+
def mostrar_mas_detalles_nr(search)
|
83
|
+
#TODO que cargue el pop up
|
84
|
+
if search.type !~ /multipledestinations/
|
85
|
+
BROWSER.div(:class=>'cluster',:index=>0).div(:class,"sub-cluster outbound").li(:class=>'stops',:index=> 0).links[0].click
|
86
|
+
Watir::Wait.until(timeout = 120){BROWSER.div(:id,'popup-detail').present?}
|
87
|
+
if BROWSER.div(:id,'popup-detail').present?
|
88
|
+
link_reglas_y_restricciones_nr(BROWSER.div(:id,'popup-detail'))
|
89
|
+
html_ida = BROWSER.div(:id,'popup-detail').html
|
90
|
+
BROWSER.div(:id,'popup-detail').span(:class,'popup-close-button popup-close').click
|
91
|
+
if search.type =~ /ida y vuelta/
|
92
|
+
BROWSER.div(:class=>'cluster',:index=>0).div(:class,"sub-cluster inbound").li(:class=>'stops',:index=> 0).links[0].click
|
93
|
+
Watir::Wait.until(timeout = 120){BROWSER.div(:id,'popup-detail').present?}
|
94
|
+
if BROWSER.div(:id,'popup-detail').present?
|
95
|
+
link_reglas_y_restricciones_nr(BROWSER.div(:id,'popup-detail'))
|
96
|
+
validar_mas_detalle_nr(html_ida,BROWSER.div(:id,'popup-detail').html)
|
97
|
+
BROWSER.div(:id,'popup-detail').span(:class,'popup-close-button popup-close').click
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
else
|
102
|
+
BROWSER.div(:class=>'cluster',:index=>0).li(:class=>'stops',:index=> 0).links[0].click
|
103
|
+
Watir::Wait.until(timeout = 120){BROWSER.div(:id,'popup-detail').present?}
|
104
|
+
if BROWSER.div(:id,'popup-detail').present?
|
105
|
+
link_reglas_y_restricciones_nr(BROWSER.div(:id,'popup-detail'))
|
106
|
+
validar_mas_detalle_nr(BROWSER.html)
|
107
|
+
BROWSER.div(:id,'popup-detail').span(:class,'popup-close-button popup-close').click
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
def link_reglas_y_restricciones_nr(elemento)
|
112
|
+
elemento.link(:class,'show-rules').click
|
113
|
+
sleep(1)
|
114
|
+
elemento.div(:class,'rules').should visible
|
115
|
+
end
|
116
|
+
def validar_mas_detalle_nr(html_ida,html_vuelta = nil)
|
117
|
+
ida = Hpricot.parse(html_ida)
|
118
|
+
vuelta = Hpricot.parse(html_vuelta) if html_vuelta
|
119
|
+
(ida/"div.segment li.itinerary span.date").select{|li| li.inner_text.empty?}.should is_empty
|
120
|
+
(ida/"div.rules/div.text").inner_text.empty?.should_not be_true
|
121
|
+
if html_vuelta
|
122
|
+
(vuelta/"div.segment li.itinerary span.date").select{|li| li.inner_text.empty?}.should is_empty
|
123
|
+
(vuelta/"div.rules/div.text").inner_text.empty?.should_not be_true
|
124
|
+
end
|
125
|
+
begin
|
126
|
+
((ida/"span.location").first.inner_text.match(/(.+)\((...)\)/)[2] == search.from_city.code).should be_true
|
127
|
+
((ida/"span.location").last.inner_text.match(/(.+)\((...)\)/)[2] == search.to_city.code).should be_true
|
128
|
+
if html_vuelta
|
129
|
+
((vuelta/"span.location").first.inner_text.match(/(.+)\((...)\)/)[2] == search.to_city.code).should be_true
|
130
|
+
((vuelta/"span.location").last.inner_text.match(/(.+)\((...)\)/)[2] == search.from_city.code).should be_true
|
131
|
+
end
|
132
|
+
rescue
|
133
|
+
true.should be_true
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
#clase que representa un precio, con su moneda y valor correspondiente
|
3
|
+
#se le pasa una string que contiene al precio(moneda y valor juntos)
|
4
|
+
class Price
|
5
|
+
|
6
|
+
include Comparable
|
7
|
+
|
8
|
+
attr_accessor :value, :currency
|
9
|
+
|
10
|
+
def initialize(precio, costos=nil, item=nil)
|
11
|
+
@currency = (precio.empty?) ? '$' : (precio.gsub(/\-|\.|\d/,'').upstrip == 'BSF' ? "Bs.F." : precio.gsub(/\-|\.|\d| /,'').upstrip )
|
12
|
+
@value = (precio.empty?) ? 0 : precio.match(/([^\s]+)\s+([^\s]+)/i)[2].strip.gsub(/\./,'').to_i
|
13
|
+
end
|
14
|
+
|
15
|
+
def moneda
|
16
|
+
self.currency
|
17
|
+
end
|
18
|
+
|
19
|
+
def valor
|
20
|
+
self.value
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_valor(value)
|
24
|
+
@value = value
|
25
|
+
end
|
26
|
+
|
27
|
+
#metodo que pregunta si el precio es en dolares
|
28
|
+
def dolar?
|
29
|
+
self.currency =~ /(U\$S)|(U\$D)|(USD)|(US\$)|(\$US)/
|
30
|
+
end
|
31
|
+
|
32
|
+
#metodos de comparacion
|
33
|
+
def <=>(other)
|
34
|
+
( (self.dolar? and other.dolar?) or self.same_moneda?(other) ) ? ( self.value <=> other.value ) : ( self.to_dolar.value <=> other.to_dolar.value)
|
35
|
+
end
|
36
|
+
|
37
|
+
#informa si la diferencia es mayor a un rango determinado
|
38
|
+
def diff(other,range)
|
39
|
+
( (self.dolar? and other.dolar?) or self.same_moneda?(other) ) ? ( self.value <=> other.value ) : ( self.to_dolar.value <=> other.to_dolar.value )
|
40
|
+
end
|
41
|
+
|
42
|
+
#devuelve un string del precio
|
43
|
+
def to_s
|
44
|
+
"#{self.currency}#{self.value}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def +(other)
|
48
|
+
( self.same_moneda?(other) )? ( Precio.new("#{self.currency} #{self.value + other.value}",true) ) : ( Precio.new("U$S #{self.to_dolar.value + other.to_dolar.value}",true) )
|
49
|
+
end
|
50
|
+
def -(other)
|
51
|
+
( self.same_moneda?(other) )? ( Precio.new("#{self.currency} #{self.value - other.value}","change") ) : ( Precio.new("U$S #{self.to_dolar.value - other.to_dolar.value}","change") )
|
52
|
+
end
|
53
|
+
|
54
|
+
def same_moneda?(other)
|
55
|
+
self.currency == other.currency or ver_moneda_en_base(other.currency) or (MainData.site =~ /ECUADOR/)
|
56
|
+
end
|
57
|
+
|
58
|
+
def zero?
|
59
|
+
self.value == 0
|
60
|
+
end
|
61
|
+
|
62
|
+
def empty?
|
63
|
+
self.zero?
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
|
3
|
+
class ProcessManager
|
4
|
+
|
5
|
+
#Crea un árbol de procesos, donde el PID recibido es el nodo raíz
|
6
|
+
def self.process_tree(pid)
|
7
|
+
tree = process_info(pid)
|
8
|
+
tree[:childs] = []
|
9
|
+
process_childs(pid).each do |child_pid|
|
10
|
+
tree[:childs].push(self.process_tree(child_pid))
|
11
|
+
end
|
12
|
+
tree
|
13
|
+
end
|
14
|
+
|
15
|
+
#Recibe un PID y devuelve un array con los PID de sus hijos
|
16
|
+
def self.process_childs(pid)
|
17
|
+
`ps -fea | grep #{pid} | grep -v grep | awk '$2!=#{pid} && $8!~/awk/ && $3==#{pid}{print $2}'`.split("\n")
|
18
|
+
end
|
19
|
+
|
20
|
+
#Devuelve un array con la información de los hijos
|
21
|
+
def self.process_childs_info(pid)
|
22
|
+
process_childs(pid).collect do |child_pid|
|
23
|
+
process_info(child_pid)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
#Devuelve un hash con la información del proceso
|
28
|
+
def self.process_info(pid)
|
29
|
+
{
|
30
|
+
:user => process_user(pid),
|
31
|
+
:pid => pid,
|
32
|
+
:parent => process_parent(pid),
|
33
|
+
:status => process_status(pid),
|
34
|
+
:cmd => process_cmd(pid)
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
#Devuelve el usuario del proceso
|
39
|
+
def self.process_user(pid)
|
40
|
+
`ps -fea | grep #{pid} | awk '$2==#{pid}{print $1}'`.split("\n")[0]
|
41
|
+
end
|
42
|
+
|
43
|
+
#Devuelve el padre del proceso
|
44
|
+
def self.process_parent(pid)
|
45
|
+
`ps -fea | grep #{pid} | awk '$2==#{pid}{print $3}'`.split("\n")[0]
|
46
|
+
end
|
47
|
+
|
48
|
+
#Devuelve el estado del proceso
|
49
|
+
def self.process_status(pid)
|
50
|
+
`ps aux | grep #{pid} | awk '$2==#{pid}{print $8}'`.split("\n")[0]
|
51
|
+
end
|
52
|
+
|
53
|
+
#Devuelve el comando del proceso
|
54
|
+
def self.process_cmd(pid)
|
55
|
+
`ps -fea | grep #{pid} | awk '$2==#{pid}{print $8}'`.split("\n")[0]
|
56
|
+
end
|
57
|
+
|
58
|
+
#Mata al proceso que recibe, si existe
|
59
|
+
def self.kill_process(pid)
|
60
|
+
begin
|
61
|
+
Process.kill('INT', pid)
|
62
|
+
#Proceso matado
|
63
|
+
true
|
64
|
+
rescue Errno::EPERM
|
65
|
+
#Permiso insuficiente para matar al proceso
|
66
|
+
begin
|
67
|
+
`kill -9 #{pid.to_i}`
|
68
|
+
true
|
69
|
+
rescue
|
70
|
+
false
|
71
|
+
end
|
72
|
+
rescue Errno::ESRCH
|
73
|
+
#El proceso no existía
|
74
|
+
true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
#Recibe un árbol de procesos y los mata a todos, incluyendo al nodo principal
|
79
|
+
def self.kill_tree(tree)
|
80
|
+
tree[:childs].each do |child|
|
81
|
+
kill_tree(child)
|
82
|
+
end
|
83
|
+
kill_process(tree[:pid].to_i)
|
84
|
+
end
|
85
|
+
|
86
|
+
#Recibe un PID y mata todo el árbol de procesos a partir de él, sin matar al nodo principal
|
87
|
+
def self.kill_all_childs(pid)
|
88
|
+
tree = process_tree(pid)
|
89
|
+
tree[:childs].each do |child|
|
90
|
+
kill_tree(child)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
#Se asegura que no queden procesos chrome zombies
|
95
|
+
def self.chrome_zombies_collector
|
96
|
+
zombies_parent = `ps -fea | grep defunct | grep chrome | grep -v grep | grep -v chromedriver | awk '{print $3}'`.split("\n")
|
97
|
+
zombies_parent.each do |parent|
|
98
|
+
parent_info = process_info(parent)
|
99
|
+
##Parent == 1, si se volvió huerfano
|
100
|
+
kill_process(parent.to_i) if parent_info[:parent] == '1' and parent_info[:cmd] and parent_info[:cmd].match(/chrome/)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Services
|
3
|
+
class Fenix
|
4
|
+
def self.start_test(id,body={},headers={})
|
5
|
+
respond = HTTParty.post("http://fenix-tools.despegar.it/fenix-tools/start-tests/#{id}",:body=>body,:headers=>headers)
|
6
|
+
puts respond
|
7
|
+
return respond
|
8
|
+
end
|
9
|
+
def self.test_status(id)
|
10
|
+
respond = JSON.parse(HTTParty.get "http://fenix-tools.despegar.it/fenix-tools/tests-status/#{id}")
|
11
|
+
return respond
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Services
|
3
|
+
|
4
|
+
class Landing
|
5
|
+
|
6
|
+
attr_accessor :json
|
7
|
+
|
8
|
+
def initialize(html)
|
9
|
+
@json = JSON.parse(get_json(html))
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_json(html)
|
13
|
+
script=(html/"script").select{|script| script.inner_text.match('jsonData')}.first
|
14
|
+
return script.inner_text.match(/^\"jsonData\" \: (.*),$/)[1]
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'digest/md5'
|
3
|
+
module Services
|
4
|
+
|
5
|
+
class Results
|
6
|
+
|
7
|
+
attr_accessor :json, :json_no_referer
|
8
|
+
|
9
|
+
def initialize(browser,type)
|
10
|
+
@json = eval "get_json_#{type}(browser)"
|
11
|
+
@json_no_referer = eval "get_json_#{type}_no_referer(browser)"
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_json_roundtrip(url,type="TOTALFARE")
|
15
|
+
begin
|
16
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING/NA/NA/NA/NA/NA?hashForData=#{digest_md5(url)}",:headers => {"referer" => url})
|
17
|
+
rescue Errno::ECONNRESET,Timeout::Error
|
18
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING/NA/NA/NA/NA/NA?hashForData=#{digest_md5(url)}",:headers => {"referer" => url})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
def get_json_oneway(url,type="TOTALFARE")
|
22
|
+
begin
|
23
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING/NA/NA/NA/NA?hashForData=#{digest_md5(url)}",:headers => {"referer" => url})
|
24
|
+
rescue Errno::ECONNRESET,Timeout::Error
|
25
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING/NA/NA/NA/NA?hashForData=#{digest_md5(url)}",:headers => {"referer" => url})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
def get_json_multipledestinations(url,type="TOTALFARE")
|
29
|
+
begin
|
30
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING?hashForData=#{digest_md5(url)}",:headers => {"referer" => url})
|
31
|
+
rescue Errno::ECONNRESET,Timeout::Error
|
32
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING?hashForData=#{digest_md5(url)}",:headers => {"referer" => url})
|
33
|
+
end
|
34
|
+
end
|
35
|
+
def get_json_roundtrip_no_referer(url,type="TOTALFARE")
|
36
|
+
begin
|
37
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING/NA/NA/NA/NA/NA")
|
38
|
+
rescue Errno::ECONNRESET,Timeout::Error
|
39
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING/NA/NA/NA/NA/NA")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
def get_json_oneway_no_referer(url,type="TOTALFARE")
|
43
|
+
begin
|
44
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING/NA/NA/NA/NA")
|
45
|
+
rescue Errno::ECONNRESET,Timeout::Error
|
46
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING/NA/NA/NA/NA")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
def get_json_multipledestinations_no_referer(url,type="TOTALFARE")
|
50
|
+
begin
|
51
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING")
|
52
|
+
rescue Errno::ECONNRESET,Timeout::Error
|
53
|
+
HTTParty.get(url.gsub(/results/,"data/search") + "/#{type}/ASCENDING")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def digest_md5(url)
|
58
|
+
return Digest::MD5.hexdigest(url+"despegar")
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
RSpec::Matchers.define :is_greater_than do |min|
|
3
|
+
match do |actual|
|
4
|
+
actual.to_i > min
|
5
|
+
end
|
6
|
+
failure_message_for_should do |actual|
|
7
|
+
"se esperaba que el valor #{actual} sea mayor a #{min}"
|
8
|
+
end
|
9
|
+
failure_message_for_should_not do |actual|
|
10
|
+
"se esperaba que el valor #{actual} no sea mayor a #{min}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec::Matchers.define :is_greater_equal_than do |min|
|
15
|
+
match do |actual|
|
16
|
+
actual.to_i >= min
|
17
|
+
end
|
18
|
+
failure_message_for_should do |actual|
|
19
|
+
"se esperaba que el valor #{actual} sea mayor o igual a #{min}"
|
20
|
+
end
|
21
|
+
failure_message_for_should_not do |actual|
|
22
|
+
"se esperaba que el valor #{actual} no sea mayor o igual a #{min}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec::Matchers.define :visible do
|
27
|
+
match do |actual|
|
28
|
+
actual.present?
|
29
|
+
end
|
30
|
+
failure_message_for_should do |actual|
|
31
|
+
"se esperaba que el elemento #{actual} sea visible"
|
32
|
+
end
|
33
|
+
failure_message_for_should_not do |actual|
|
34
|
+
"se esperaba que el elemento #{actual} no sea visible"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
RSpec::Matchers.define :enabled do
|
39
|
+
match do |actual|
|
40
|
+
actual.enabled?
|
41
|
+
end
|
42
|
+
failure_message_for_should do |actual|
|
43
|
+
"se esperaba que el elemento #{actual} estuviera habilitado"
|
44
|
+
end
|
45
|
+
failure_message_for_should_not do |actual|
|
46
|
+
"se esperaba que el elemento #{actual} estuviera deshabilitado"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
RSpec::Matchers.define :visible do |text|
|
51
|
+
match do |actual|
|
52
|
+
actual.present?
|
53
|
+
end
|
54
|
+
failure_message_for_should do |actual|
|
55
|
+
"se esperaba que el elemento #{text} sea visible"
|
56
|
+
end
|
57
|
+
failure_message_for_should_not do |actual|
|
58
|
+
"se esperaba que el elemento #{text} no sea visible"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
RSpec::Matchers.define :match do |text_for_match|
|
63
|
+
match do |actual|
|
64
|
+
actual.match(/#{text_for_match}/)
|
65
|
+
end
|
66
|
+
failure_message_for_should do |actual|
|
67
|
+
"se esperaba que el texto #{actual} contenga a #{text_for_match}"
|
68
|
+
end
|
69
|
+
failure_message_for_should_not do |actual|
|
70
|
+
"se esperaba que el texto #{actual} no contenga a #{text_for_match}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
RSpec::Matchers.define :match_sensitive do |text_for_match|
|
75
|
+
match do |actual|
|
76
|
+
actual.match(/#{text_for_match}/i)
|
77
|
+
end
|
78
|
+
failure_message_for_should do |actual|
|
79
|
+
"se esperaba que el texto #{actual} contenga a #{text_for_match}"
|
80
|
+
end
|
81
|
+
failure_message_for_should_not do |actual|
|
82
|
+
"se esperaba que el texto #{actual} no contenga a #{text_for_match}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
RSpec::Matchers.define :equal do |text|
|
87
|
+
match do |actual|
|
88
|
+
actual == text
|
89
|
+
end
|
90
|
+
failure_message_for_should do |actual|
|
91
|
+
"se esperaba que el texto #{actual} sea igual a #{text}"
|
92
|
+
end
|
93
|
+
failure_message_for_should_not do |actual|
|
94
|
+
"se esperaba que el texto #{actual} no sea igual a #{text}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
RSpec::Matchers.define :include? do |text|
|
99
|
+
match do |actual|
|
100
|
+
actual.include?(text)
|
101
|
+
end
|
102
|
+
failure_message_for_should do |actual|
|
103
|
+
"se esperaba que la coleccion [#{actual.join('-')}] contenga a #{text}"
|
104
|
+
end
|
105
|
+
failure_message_for_should_not do |actual|
|
106
|
+
"se esperaba que la coleccion [#{actual.join('-')}] no contenga a #{text}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
RSpec::Matchers.define :is_empty do
|
111
|
+
match do |actual|
|
112
|
+
actual.empty?
|
113
|
+
end
|
114
|
+
failure_message_for_should do |actual|
|
115
|
+
"Se esperaba que la coleccion #{actual.join('-')} sea vacia"
|
116
|
+
end
|
117
|
+
failure_message_for_should_not do |actual|
|
118
|
+
"Se esperaba que la coleccion #{actual.join('-')} no sea vacia"
|
119
|
+
end
|
120
|
+
end
|