0

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

questionasker
  • 2,536
  • 12
  • 55
  • 119
m0bbin
  • 166
  • 2
  • 13
  • 1
    You should try to search keyword "innerHTML" since all subelements of
    may be in type of innertext/innerHtml.
    – Huynh Jun 30 '19 at 12:02
  • you may take a look some questions like this: https://stackoverflow.com/questions/7263824/get-html-source-of-webelement-in-selenium-webdriver-using-python . or this: https://stackoverflow.com/questions/56644605/unable-to-print-text-of-options-in-select-in-selenium-python – Huynh Jun 30 '19 at 12:04

0 Answers0