[英]How do you click a javascript button using python selenium
I want to click this button on a webpage with selenium 我想在带有硒的网页上单击此按钮
heres the html for the button 这是按钮的html
<div class="wdpv_vote_up ">
<input value="7787" type="hidden">
<input class="wdpv_blog_id" value="1" type="hidden">
</div>
and heres the javascript for that 和这的JavaScript
function voteUp() {
if (!$(this).hasClass("wdpv_disabled")) {
doVote($(this), "+1");
}
return false;
}
I want to be able to click that button but I dont know how , anny idea's ? 我希望能够单击该按钮,但是我不知道如何,安妮的想法是?
Try clicking the div-Element directly, like this: 尝试直接单击div-Element,如下所示:
driver.findElement(By.xpath("contains(@class, 'wdpv_vote_up')")).click();
I used xpath and contains, because your div-element's class attribute has a space included, don't know if this is a typo, or there might be other classes in the original code as well... 我使用了xpath并包含它,因为您的div-element的class属性包含一个空格,不知道这是拼写错误,还是原始代码中可能还有其他类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.