admin管理员组文章数量:1426035
I am using Python/Selenium to click on an icon on a web site which downloads a file. I know how to click on regular buttons using Selenium but this one is a bit tricky as it's not a regular button and it's making a Javascript call. I've tried several find_element_by calls but was unable to access this element. Can anyone think of a way to click on this using a selenium call?
When I do inspect element for the download icon in my web browser this is what I get:
<a href="javascript: void(0)" class="pull-right margin-r" onclick="
document.theForm.action='/p1234/DownloadData';
$('#theForm').append($('<input>', {type:'hidden', name:'Download', value:'Download'})).submit();
"><img src="/images/download.png" title="Download" alt="Download" style="" border="0"></a>
thanks in advance
I am using Python/Selenium to click on an icon on a web site which downloads a file. I know how to click on regular buttons using Selenium but this one is a bit tricky as it's not a regular button and it's making a Javascript call. I've tried several find_element_by calls but was unable to access this element. Can anyone think of a way to click on this using a selenium call?
When I do inspect element for the download icon in my web browser this is what I get:
<a href="javascript: void(0)" class="pull-right margin-r" onclick="
document.theForm.action='/p1234/DownloadData';
$('#theForm').append($('<input>', {type:'hidden', name:'Download', value:'Download'})).submit();
"><img src="/images/download.png" title="Download" alt="Download" style="" border="0"></a>
thanks in advance
Share Improve this question edited Apr 30, 2016 at 20:21 user3695968 asked Apr 30, 2016 at 20:11 user3695968user3695968 331 gold badge1 silver badge5 bronze badges1 Answer
Reset to default 2How about locating the element by the part of the onclick
attribute:
driver.find_element_by_css_selector("a[onclick*=DownloadData]").click();
where *=
means "contains".
本文标签: How to simulate onclick (JavaScript) using SeleniumPythonStack Overflow
版权声明:本文标题:How to simulate onclick (JavaScript) using SeleniumPython - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745462030a2659366.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论