Module: Search

Defined in:
lib/page_objects/modules/search.rb

Instance Method Summary collapse

Instance Method Details

#perform_assistance_search(region) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/page_objects/modules/search.rb', line 72

def perform_assistance_search(region)

  from_date = (Time.now + 2629743).strftime('%Y-%m-%d')

  to_date = (Time.now + 2629743 + 604800).strftime('%Y-%m-%d')

  # http://www.decolar.com/assistance/#!/search/#{region}/#{from_date}/#{to_date}/2

  DestinationServicesGUI.set_cookie({'X-Version-Override' => BETA_COOKIES}) if BETA

  browser.refresh

  url = $DOMAIN + '/assistance/#!' + "/search/#{region}/#{from_date}/#{to_date}/2"

  browser.goto(url)

  t = 0

  while t < 60 && ( !browser.div(:class, 'ds-assistance-title').present? || !browser.div(:class, 'ux-assistance-landing-title').present? )
    sleep 1
    t += 1
  end

  # browser.div(:class, 'ux-common-grid-row ux-assistance-landing-filters').wait_until_present(60)

end

#perform_search(destination = nil, date = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/page_objects/modules/search.rb', line 28

def perform_search(destination = nil, date = nil)

  search_box = browser.div(:class, 'pdt-activities')

  destination = DestinationServicesGUI::Search.convert_to_city_name(TO_CITY)

  dates = []

  date_select = browser.div(:class, 'com-month-activities').select(:class, 'sb-month')

  if date.nil?
    dates = date_select.options.to_a
    dates = dates.collect{ | d | d.text }
    dates = dates[1..5]
    date = dates.shuffle.pop
  end

  adults ||= 2

  children ||= 2

  destination_field = browser.text_field(:id, 'sb-destination-activities')
  destination_field.set(destination)
  sleep(8) # implementar wait para el servicio de autocomplete

  search_box.div(:class,'com-city-hotels destination').uls.first.li(:class, 'first').click

  date_select.select(date)

  browser.select_list(:class, 'adult').select(adults) if adults > 0

  if children > 0
    search_box.select_list(:class, 'child').select(children)
    1.upto (children) do |n|
      search_box.li(:class, "ctn-#{n}").select_list(:class, 'sb-age').select(rand(3..9))
    end
  end

  puts "    TO_CITY: #{TO_CITY}  "

  search_box.a(:class, 'ctn-searchbutton').click

end

#perform_search_for_tracking_id(trackingId) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/page_objects/modules/search.rb', line 13

def perform_search_for_tracking_id(trackingId)

  destination = get_destination_from_tracking_id(trackingId)

  url = get_domain_by_country + destination

  browser.goto(url)

  wait_for_results

  browser.goto(url) unless browser.url.include?("#{url}")

end

#perform_search_from_seo_urlObject



5
6
7
8
9
10
11
# File 'lib/page_objects/modules/search.rb', line 5

def perform_search_from_seo_url

  url = get_domain_by_country + TO_CITY

  browser.goto(url)

end