Skip to content

Commit

Permalink
latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
edulima committed Aug 15, 2015
2 parents 24f4450 + d3f04ce commit 1bda032
Showing 1 changed file with 209 additions and 22 deletions.
231 changes: 209 additions & 22 deletions spec/features/test_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

background do
visit config['url']
puts "testsetset" + config['title']
expect(page).to have_title config['']
end

Expand All @@ -20,6 +19,7 @@

visit config['url_visa']

<<<<<<< HEAD


#page.find('#MainContent_LinkButtonNext').click
Expand All @@ -28,29 +28,62 @@


# end
=======
page.find('#MainContent_LinkButtonNext').click
>>>>>>> d3f04ce4be78e7302d1ff758d73106d036b0baeb

available_dates = Array.new
days_on_calendar = Array.new
available_times = Array.new

days_of_month = ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"]
#days_of_month = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,34]

# page.all(:table, 'MainContent_AppointmentDateTime1_Control_Calendar1_Calendar_Calendar1_Calendar1').each do |el|
unavailable = page.all('.aspNetDisabled')

#start of first calendar
findBookedDays = page.all('.aspNetDisabled')

myArray = countArrayElements(unavailable)
bookedDays = countArrayElements(findBookedDays)

inc = 0
for i in days_of_month
calculateDays(days_of_month, bookedDays, available_times, available_dates, getCurrentMonth())

sleep 3

clickNextMonthLink()


#start of second calendar
findBookedDays = page.all('.aspNetDisabled')

puts "day of the month: #{days_of_month[inc]}"
puts "number of days found: #{myArray.count(days_of_month[inc])}"
bookedDays = countArrayElements(findBookedDays)

calculateDays(days_of_month, bookedDays, available_times, available_dates, "sep")


sleep 3

# inc = 0
# for i in days_of_month

# available_times.clear

<<<<<<< HEAD
str = myArray.count(days_of_month[inc])
inc = inc + 1
end
=======
# str = bookedDays.count(days_of_month[inc])

# tempDay = getAvailableDays(str, days_of_month[inc])

# if tempDay != nil

# available_dates.push(tempDay)

# clickOnAvailableDay(tempDay)
>>>>>>> d3f04ce4be78e7302d1ff758d73106d036b0baeb

# tempArray = getAvailableTime()

<<<<<<< HEAD
counter = 0

for i in days_of_month
Expand All @@ -73,28 +106,182 @@
# end

counter = counter + 1
=======
# t = 0
# for i in tempArray

# #at this point multi
# available_times.push(tempArray[t].text)

# t += 1

# end

# puts "for day #{tempDay} of #{find_current_month} there are #{available_times.length} time slots available"

# end

# inc = inc + 1

# end


for i in available_dates

#puts "We found the day: #{available_dates[counter.to_i]} of #{find_current_month}"
>>>>>>> d3f04ce4be78e7302d1ff758d73106d036b0baeb

end

# end


sleep 10
puts getNextMonth()
sleep 5



end

end


def countArrayElements(array)
inc = 0

newArray = []
inc = 0
for i in array
newArray.push(array[inc].text)
inc +=1
end

newArray.push(array[inc].text)
#puts "element: #{newArray[inc]} times: #{newArray.count(newArray[inc])}"
inc = inc + 1

end
return newArray

end


def setAugustCalendar()

calendar = Array.new
calendar = ["27", "28", "29", "30", "31","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","1","2","3","4","5","6"]

return calendar

end

def setSeptemberCalendar()

calendar = Array.new
calendar = ["31","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","1","2","3","4"]

return calendar

end


def getAvailableDays(str, dayOfMonth, month)

if str == 0

return dayOfMonth

elsif str == 1

if month == "August"

countDaysOnMontg = setAugustCalendar()
days = countDaysOnMontg.count(dayOfMonth)

if days == 2
return dayOfMonth
end

elsif month == "sep"

countDaysOnMontg = setSeptemberCalendar()
days = countDaysOnMontg.count(dayOfMonth)

if days == 2
return dayOfMonth
end

end
end

end

def clickNextMonthLink()

within("table#MainContent_AppointmentDateTime1_Control_Calendar1_Calendar_Calendar1_Calendar1") {
find(:xpath, "//a[contains(@title, \"next\")]").click }

end

def clickOnAvailableDay(day)

within("table#MainContent_AppointmentDateTime1_Control_Calendar1_Calendar_Calendar1_Calendar1") {
find(:xpath, "//a[contains(@title, \"#{day}\")]").click }

end

def getAvailableTime()
timesAvailable = page.all('.CalendarSlot_DataList_Item')
return timesAvailable
end



def findCurrentMonth()
page.all(:table, 'MainContent_AppointmentDateTime1_Control_Calendar1_Calendar_Calendar1_Calendar1').each do |el|
ar = el.text
return ar.scan("August")
end

end

def getCurrentMonth()
return Time.now.strftime("%B")
end

def getNextMonth()
return Date.today.next_month.strftime("%B")
end


def calculateDays(days_of_month, bookedDays, available_times, available_dates, calendar)

inc = 0
for i in days_of_month

available_times.clear

countBookedDays = bookedDays.count(days_of_month[inc])

tempDay = getAvailableDays(countBookedDays, days_of_month[inc], calendar)

if tempDay != nil

available_dates.push(tempDay)

clickOnAvailableDay(tempDay)

tempArray = getAvailableTime()

t = 0
for i in tempArray

available_times.push(tempArray[t].text)

t += 1

end

puts "for day #{tempDay} of #{getCurrentMonth()} there are #{available_times.length} time slots available"

end

inc = inc + 1

end
end





0 comments on commit 1bda032

Please sign in to comment.