I want to click the button on one website. My selectors highlight the button in google chrome console so it must be proper. When I send click() it returns undefined. What might be the possible reason of this happening ? My code is short and I put it directly to the chrome console:
document.querySelector("div#content table#content_table tbody tr td div#content_middle div div:nth-child(3) div button").click();
This works:
<button onclick="alert('button was clicked.');">click me</button>
<script>
document.querySelector("button").click();
</script>
Do you have an onclick function bound to the element?
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.