Below I have a python script that can do the following:
- Find selected date
- Choose next available date
- If no available date is found within a month, click next to the transition point to the next month.
My question is that I just want to turn on ide verson selenium only where a person just needs to record his steps. Is there a way to convert the code that I have below into commands, goals and values โโin the IDE so that it does the same? If you can provide a list of commands, goals, and values โโin order, then this will be really helpful.
The website I am testing on is www.jet2.com and this concerns the departure date.
Cause. I just want to convert to an IDE only in the future, when manually testing, I can just use the IDE playback to do the rest of the tests. Clydear was the only glitch that was solved using the python method.
datepicker = driver.find_element_by_id("departure-date-selector")
actions.move_to_element(datepicker).click().perform()
calendar = driver.find_element_by_id("departureDateContainer")
month_picker = Select(calendar.find_element_by_class_name("ui-datepicker-month"))
year_picker = Select(calendar.find_element_by_class_name("ui-datepicker-year"))
current_date = calendar.find_element_by_class_name("ui-datepicker-current-day")
month = month_picker.first_selected_option.text
year = year_picker.first_selected_option.text
print("Current date: {day} {month} {year}".format(day=current_date.text, month=month, year=year))
try:
next_available_date = current_date.find_element_by_xpath("following::td[@data-handler='selectDay' and ancestor::div/@id='departureDateContainer']")
print("Found an available date: {day} {month} {year}".format(day=next_available_date.text, month=month, year=year))
next_available_date.click()
except NoSuchElementException:
while True:
try:
calendar.find_element_by_class_name("ui-datepicker-next").click()
except NoSuchElementException:
year = Select(calendar.find_element_by_class_name("ui-datepicker-year"))
year.select_by_visible_text(str(int(year.first_selected_option.text) + 1))
month = Select(calendar.find_element_by_class_name("ui-datepicker-month")).first_selected_option.text
year = Select(calendar.find_element_by_class_name("ui-datepicker-year")).first_selected_option.text
print("Processing {month} {year}".format(month=month, year=year))
try:
next_available_date = calendar.find_element_by_xpath(".//td[@data-handler='selectDay']")
print("Found an available date: {day} {month} {year}".format(day=next_available_date.text, month=month, year=year))
next_available_date.click()
break
except NoSuchElementException:
continue
source
share