data-monkey
data-monkey

Reputation: 1705

How to click on a in-line tab with Python Selenium

I'm on a webpage with the following code:

from selenium import webdriver
from bs4 import BeautifulSoup

driver = webdriver.Chrome('C:/.../chromedriver_win32/chromedriver')
link = 'http://performance.morningstar.com/funds/etf/total-returns.action?t=IWF'
driver.get(link)

How do I click on this tab called "Monthly":

enter image description here

EDIT:

The HTML that corresponds to this section is:

enter image description here

In this case, what "element" should I select to click on?

Upvotes: 0

Views: 2616

Answers (1)

Davide Patti
Davide Patti

Reputation: 3471

You can do in this way:

elem1= driver1.find_element_by_xpath("//ul[@class='in_tabs']")
elem1.find_element_by_xpath(".//a[@tabname='#tabmonth']").click()

As you can imagine, with the first you select the element in_tabs and with the second the interested element.

Upvotes: 2

Related Questions