find clickable xpath on a webpage

on below NSE site, I need to click the Download (.csv) button through selenium and I am using below code but its not working-

Site: https://www.nseindia.com/option-chain

Code:

link = driver.find_elements_by_xpath('//*[@id="downloadOCTable"]')
link.click

enter image description here

>Solution :

First of all find_elements_by_xpath returns you a list, what you would need is browser.find_element_by_xpath("//*[@id="downloadOCTable"]").

Store the returned object instance in a variable say element_click.
Then call click on it as

element_click.click()

This should work, or alternatively you can try

link = driver.find_elements_by_xpath('//*[@id="downloadOCTable"]')
link[0].click()

Leave a Reply