2017-10-19 35 views
-1

我在用下面的代碼網頁:如何點擊在線選項卡上使用Python硒

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) 

如何單擊該選項卡稱爲「月刊」上:

enter image description here

EDIT

對應於本節中的HTML是:

enter image description here

在這種情況下,我應該選擇什麼「元素」來點擊?

+0

element = driver.find_element('XX') element.click()? – rak007

+0

是的,我剛纔問的是什麼「元素」,我應該找... –

+0

然後你應該查看html並找到標籤 – JAW

回答

1

你可以這樣做:

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

正如你可以想像,第一個選擇的元素in_tabs,並與第二感興趣的元素。

相關問題