in selenium web driver how to choose the correct iframe

0
0

I’m trying to click on an element on this page:

url = 'https://finance.yahoo.com/quote/GOOG?ltr=1'
driver
= webdriver.Firefox()
driver
.get(url)
driver
.find_element_by_link_text('Financials')

At this point I would like to click on ‘Cash Flow’, ‘Balance Sheet’, or ‘Quarterly’. I know these buttons have been loaded because I can extract them using BeautifulSoup from the page source. But when I try to do it using Selenium:

driver.find_element_by_link_text('Cash Flow')
driver
.find_element_by_link_text('Balance Sheet')
driver
.find_element_by_link_text('Quarterly')

All return ‘Unable to locate element’ except for ‘Quarterly’ which returns an element but its the one sitting above the graph and not the one above the table which is what I’m interested in.

I think this is due to being in the wrong iframe, and I have located all iframes:

driver.find_elements_by_tag_name('iframe')

which returns 9 elements. But I’m having trouble figuring which iframe the elements I want to click on belong to. I also went through the iframes sequentially and still couldn’t find the elements I’m interested in.

  • You must to post comments
Showing 0 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website