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=""> </span>
<span id="toolbarbutton-1054-btnInnerEl" data-ref="btnInnerEl" unselectable="on" class="x-btn-inner x-btn-inner-transparent-medium">
</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")
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')
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.