Convert python selenium to selenium ide commands

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.

# 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
+4
source share
1 answer

I think I canโ€™t with a 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 conditional expressions, function calls , error detection and JSON / XML

0
source

Source: https://habr.com/ru/post/1627654/


All Articles