'Click a button inside <span> using Python Selenium

I am trying to click on download button. The HTML Code for the button is as below:

<a class="x-btn toolbar-menu x-unselectable x-box-item x-toolbar-item x-btn-transparent-medium" style="padding: 0px 5px; right: auto; left: 1121px; margin: 0px; top: 0px;" hidefocus="on" unselectable="on" id="toolbarbutton-1054" tabindex="-1" data-qtip="<b>Export</b><br/>Export your report into a CSV file." componentid="toolbarbutton-1054">
<span id="toolbarbutton-1054-btnWrap" data-ref="btnWrap" role="presentation" unselectable="on" style="" class="x-btn-wrap x-btn-wrap-transparent-medium ">
<span id="toolbarbutton-1054-btnEl" data-ref="btnEl" role="presentation" unselectable="on" style="" class="x-btn-button x-btn-button-transparent-medium  x-btn-no-text x-btn-icon x-btn-icon-left x-btn-button-center ">
<span id="toolbarbutton-1054-btnIconEl" data-ref="btnIconEl" role="presentation" unselectable="on" class="x-btn-icon-el x-btn-icon-el-transparent-medium sdc-icon-export " style="">&nbsp;</span>
<span id="toolbarbutton-1054-btnInnerEl" data-ref="btnInnerEl" unselectable="on" class="x-btn-inner x-btn-inner-transparent-medium">&nbsp;
</span>
</span>
</span>
</a>

I tried this :

driver.find_element(By.ID , "toolbarbutton-1054-btnEl").click()

Getting an error: selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

When I try below command it does not give error and element is recognizable. It's just that I cannot click on it.

driver.find_element(By.ID , "toolbarbutton-1054-btnEl") 


Solution 1:[1]

Hey you can use the below code

class_element= driver.find_element_by_class('x-btn toolbar-menu x-unselectable x-box-item x-toolbar-item x-btn-transparent-medium')
class_element.click()

and also you can use driver.find_element_by_xpath('xpath here')

Solution 2:[2]

Actually, Span does not have a clickable feature.

Please execute the following javascript code using python selenium:

document.getElementById('toolbarbutton-1054-btnEl').click();

I don't know how to execute javascript code using python selenium but it will work.

I used it with C# Selenium.

Solution 3:[3]

In Python it should work with the following code:

s=driver.find_element(By.ID , "toolbarbutton-1054-btnEl")
driver.execute_script("arguments[0].click();",s)

I used the link below for my reference:
https://www.tutorialspoint.com/running-javascript-in-selenium-using-python

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arham Sanghvi
Solution 2 Nileksh Dhimer
Solution 3 Gino Mempin