Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

Below I have a python script that is able to perform the following:

  • Find the current date selected
  • Select the next available date
  • If no available date is found within the month, press next to go to next month

My question is that I also just want to included a selenium ide verson only where the person just needs to record their steps. Is there a way to convert the code I have below into commands, targets and values in IDE so it does the same thing? If you can provide a list of the commands, targets and values in order then will be really helpful.

The website I'm testing on is www.jet2.com and it's in regards to the departure date.

Reason I just want to convert in IDE only is so in future when manual testing, I can just use the IDE playback to perform the rest of the tests. The claendar was the only glitch I had which is solved using the python method.

# select date
datepicker = driver.find_element_by_id("departure-date-selector")
actions.move_to_element(datepicker).click().perform()

# find the calendar, month and year picker and the current date
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")

# printing out current date
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))

# see if we have an available date in this month
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:
# looping over until the next available date found
        while True:
# click next, if not found, select the next year
            try:
                calendar.find_element_by_class_name("ui-datepicker-next").click()
            except NoSuchElementException:
# select next year
                year = Select(calendar.find_element_by_class_name("ui-datepicker-year"))
                year.select_by_visible_text(str(int(year.first_selected_option.text) + 1))

# reporting current processed month and year
                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
share|improve this question
    
I know this doesn't answer your question, but before you consider IDE in your long-term plans it might be worth checking stackoverflow.com/questions/19683100/… – Andrew Regan Feb 7 at 12:08
    
Hi andrew, I actually viewed this page before. I want to use IDE so then I can show those who are new to automation a quick way to get into it before using web driver when we go more advanced down the road. Some testers don't have a development background you see – BruceyBandit Feb 7 at 12:16
    
OK, but I think the attitude from Selenium is that WebDriver is the standard rather than the advanced approach, and non-devs should use one of the many frameworks or DSLs. Having managed non-technical testers I'd say that they can be at least as productive with a decent DSL as with the IDE. – Andrew Regan Feb 7 at 12:24

I guess I's impossible with pure Selenium IDE but you can use plugins like FlowControl or SelBlocks to get if-else, goto and loop functionality as well as javascript-like conditionals, callable functions, error catching, and JSON/XML driven parametrization.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.