Module: Commons
- Included in:
- DestinationServicesGUI::Checkout, DestinationServicesGUI::Detail, DestinationServicesGUI::Results, DestinationServicesGUI::Search
- Defined in:
- lib/page_objects/modules/commons.rb
Instance Method Summary collapse
- #alert_handle ⇒ Object
- #convert_to_city_name(iata) ⇒ Object
- #get_destination_from_tracking_id(trackingId) ⇒ Object
- #get_provider_code(cluster) ⇒ Object
- #get_tracking_id(cluster) ⇒ Object
- #set_country(country) ⇒ Object
- #set_domain ⇒ Object
- #show_results_tracking_id ⇒ Object
- #show_transfer_results_tracking_id ⇒ Object
- #wait_for_cart_pricebox_spinner ⇒ Object
- #wait_for_checkout ⇒ Object
- #wait_for_detail ⇒ Object
- #wait_for_disney_loader ⇒ Object
- #wait_for_modal ⇒ Object
- #wait_for_results ⇒ Object
- #wait_for_results_cart_spinner ⇒ Object
- #wait_for_transfer_results ⇒ Object
- #wait_for_universal_loader ⇒ Object
Instance Method Details
#alert_handle ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/page_objects/modules/commons.rb', line 183 def alert_handle alert_not_present = true max_retries = 0 while alert_not_present and (max_retries < 3) alert = browser.driver.switch_to.alert rescue 'Alert not present' alert_not_present = false unless alert == 'Alert not present' sleep 1 max_retries += 2 end browser.driver.switch_to.alert.accept if !alert_not_present end |
#convert_to_city_name(iata) ⇒ Object
3 4 5 6 7 |
# File 'lib/page_objects/modules/commons.rb', line 3 def convert_to_city_name(iata) geo_response = HTTParty.get("http://10.2.7.6/geo-services-web/service/webcontext/City/getCityByCityCode/#{iata}") #geo_response = HTTParty.get("http://10.254.168.100/geo-services-web/service/webcontext/City/getCityByCityCode/#{iata}") city_name = geo_response['data']['geoAreaDescriptions'].reject{|key| key if !key['languageCode'].eql?("ES")}[0]['name'] end |
#get_destination_from_tracking_id(trackingId) ⇒ Object
42 43 44 45 46 |
# File 'lib/page_objects/modules/commons.rb', line 42 def get_destination_from_tracking_id(trackingId) trackingId.split('_')[1] end |
#get_provider_code(cluster) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/page_objects/modules/commons.rb', line 26 def get_provider_code(cluster) cluster = cluster.li(:class, 'providers').text.split('_').first.split(' ').last cluster end |
#get_tracking_id(cluster) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/page_objects/modules/commons.rb', line 34 def get_tracking_id(cluster) cluster = cluster.span(:class, 'providers').text.split(':').last.strip cluster end |
#set_country(country) ⇒ Object
48 49 50 51 |
# File 'lib/page_objects/modules/commons.rb', line 48 def set_country(country) $SITE = country set_domain end |
#set_domain ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/page_objects/modules/commons.rb', line 53 def set_domain if $SITE == 'BR' $DOMAIN='http://www.decolar.com' elsif $SITE == 'CR' $DOMAIN='http://www.despegar.co.cr' elsif $SITE == 'CL' $DOMAIN='http://www.despegar.cl' elsif $SITE == 'US' $DOMAIN='http://www.us.despegar.com' else $DOMAIN="http://www.despegar.com.#{$SITE.downcase}" end end |
#show_results_tracking_id ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/page_objects/modules/commons.rb', line 9 def show_results_tracking_id results_script = %Q(javascript: ( function(){var providers = $(".providers"); providers.filter(":visible").length > 0 ? providers.hide() : providers.show()})();) browser.execute_script(results_script) sleep 2 end |
#show_transfer_results_tracking_id ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/page_objects/modules/commons.rb', line 18 def show_transfer_results_tracking_id results_script = %Q(javascript:( function(){var priceboxes = $(".ux-cluster-pricebox"); angular.forEach(priceboxes, function(elem, index){var ngElem= angular.element(elem); $(elem).append('<div class="transfer-provider">' + ngElem.scope().transfer.provider + '</div>').find(".transfer-provider").css({'color': 'red', 'font-weight': 'bold'});});})();) browser.execute_script(results_script) sleep 2 end |
#wait_for_cart_pricebox_spinner ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/page_objects/modules/commons.rb', line 169 def wait_for_cart_pricebox_spinner timeout = 0 alert_handle while browser.span(:class, 'ux-pricebox-spinner').visible? and timeout < 40 alert_handle sleep 3 timeout += 3 end end |
#wait_for_checkout ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/page_objects/modules/commons.rb', line 141 def wait_for_checkout timeout = 0 alert_handle while !browser.div(:class, 'ux-common-checkout-payment-method').present? and timeout < 60 alert_handle sleep 3 timeout += 3 end end |
#wait_for_detail ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/page_objects/modules/commons.rb', line 85 def wait_for_detail timeout = 0 alert_handle while !browser.div(:class, 'ux-destination-services-detail-pricebox').present? and timeout < 60 alert_handle sleep 6 timeout += 6 end end |
#wait_for_disney_loader ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/page_objects/modules/commons.rb', line 99 def wait_for_disney_loader timeout = 0 alert_handle while browser.div(:class, 'ux-destination-services-detail-disney-pricebox-loading').visible? and timeout < 40 alert_handle sleep 3 timeout += 3 end end |
#wait_for_modal ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/page_objects/modules/commons.rb', line 127 def wait_for_modal timeout = 0 alert_handle while browser.div(:class, 'modal').present? and timeout < 40 alert_handle sleep 3 timeout += 3 end end |
#wait_for_results ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/page_objects/modules/commons.rb', line 69 def wait_for_results cart_icon = browser.div(:class, 'ds-my-tickets') timeout = 0 alert_handle while !cart_icon.present? and timeout < 60 alert_handle sleep 3 timeout += 3 end end |
#wait_for_results_cart_spinner ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/page_objects/modules/commons.rb', line 153 def wait_for_results_cart_spinner browser.div(:class, 'ds-cart-content').hover timeout = 0 alert_handle while browser.div(:class, 'ux-shopping-cart-spinner-overlay').span(:class, 'ux-shopping-cart-spinner').visible? and timeout < 40 alert_handle sleep 3 timeout += 3 end end |
#wait_for_transfer_results ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/page_objects/modules/commons.rb', line 195 def wait_for_transfer_results timeout = 0 title = browser.span(:class, 'ux-home-title-disclaimer') while !title.present? and timeout < 60 sleep 3 timeout += 3 end end |
#wait_for_universal_loader ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/page_objects/modules/commons.rb', line 113 def wait_for_universal_loader timeout = 0 alert_handle while browser.div(:class, 'ux-destination-services-detail-universal-pricebox-loading').visible? and timeout < 40 alert_handle sleep 3 timeout += 3 end end |