【发布时间】:2018-04-22 15:32:31
【问题描述】:
使用 Selenium 单击链接(下载文件)。尝试过 xpath、逐文本元素等,但没有奏效。该元素如下所示:
<span class="download-data-link"><a download="" target"_blank"="" style="cursor:pointer">Download file in csv format</a></span>
我在使用 xpath 方法时遇到的错误:
downloadWithSelenium(currDate,fileName, fileLink)
File "D:\code\portfolio\downloadWithSelenium.py", line 27, in downloadWithSelenium
browser.find_element_by_xpath("//*[@id='historicalData']").click()
File "C:\Users\susmeher\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\susmeher\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "C:\Users\susmeher\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Users\susmeher\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.15063 x86_64)
【问题讨论】:
标签: python selenium selenium-webdriver xpath webdriver