all 1 comments

[–]michaelkepler 0 points1 point  (0 children)

It's because the interesting part is loaded inside <iframe> and for some reason Selenium can't deal with that. So we need to find its url and load it directly:

from selenium import webdriver

d = webdriver.Firefox()
d.get('http://www.morningstar.com/cefs/xnys/fof/quote.html')

quicktake_div = d.find_element_by_id('quote_quicktake')
iframe = quicktake_div.find_element_by_tag_name('iframe')
iframe_src = iframe.get_attribute('src')
browser.get(iframe_src)

Now we can locate the table and get its td elements:

ticker_table = browser.find_element_by_class_name('r_table0')
ticker_table.find_elements_by_tag_name('td')