I want to be able to scrape ticket information from this website. I currently am receiving a stale error issue when trying access elements after switching to iframe. I want to be able to loop through the calendar days and be able to see available tickets for different days.
I have tried to access the iframe with different approaches like using WebDriverWait().until(EC.frame_to_avaiable_and_switch_to_it()
and also tried to find the iframe element using XPATH
, CLASS_NAME
and CSS_SELECTOR
.
def get_available_dates(driver, delay=30):
elm = (By.XPATH, '//iframe')
iframe = WebDriverWait(driver, delay).until(EC.frame_to_be_available_and_switch_to_it(elm))
iframes = driver.find_elements_by_xpath("//iframe")
print len(iframes) #Sometimes this shows 0, 1, or 5
driver.switch_to.frame(iframe) #sometimes throw error
elm = (By.CLASS_NAME, 'CalendarMonth_table.CalendarMonth_table_1')
calendar_table = WebDriverWait(driver, delay).until(EC.presence_of_element_located(elm)) #Throws Timeout Exception or iframe stale error
rows = calendar_table.find_elements_by_tag_name('tr')
print "row cnt: {}".format(len(rows))
print rows
I added expected results and errors as comments