elem_selected_year = driver.find_element_by_class_name("ui-datepicker-year") selected_year_string = elem_selected_year.get_attribute("innerHTML") elem_selected_month = driver.find_element_by_class_name("ui-datepicker-month") selected_month_string = elem_selected_month.get_attribute("innerHTML") # Concatenate selected month and year strings selected_month_year_string = selected_month_string + selected_year_string previous_button_xpath = "//*[@id='ui-datepicker-div']/div/a[1]" next_button_xpath = "//*[@id='ui-datepicker-div']/div/a[2]"