【发布时间】:2020-08-01 02:04:48
【问题描述】:
我希望我可以在下拉菜单中选择所有股票,点击“搜索”按钮并点击“导出为 CSV”按钮。但是,我被卡在选择选项后无法点击“搜索”按钮。请指教。谢谢
from selenium import webdriver
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from time import ctime
browser = webdriver.Chrome()
browser.get("https://www.hkex.com.hk/eng/sorc/options/statistics_hv_iv.aspx")
select = Select(WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH,
"//select[@id='underlying']"))))
browser.implicitly_wait(10)
optionsList = []
#iterate over the options, place attribute value in list
for option in select.options:
option.click()
optionsList.append(option.get_attribute("value"))
# below code is not able to work properly but this is only what I am hoping to work
elem = browser.find_element_by_link_text("Search")
elem.click()
elem1 = driver.find_element_by_link_text("Export to CSV")
elem1.click()
print(elem)
print(optionsList)
print(len(optionsList))
browser.quit
【问题讨论】:
标签: python selenium xpath css-selectors webdriverwait