I'm writing a web scraper using Selenium
/Python
, and I need to access and call the onclick handler of a specific element using execute_script
. Seems the event listener is set via addEventListener()
rather than assign the onclick
property of the element, so the onclick
property of the element is null
.
I can easily access the handler at Chrome Developer Console using the getEventListeners
function, but since the function is limited to Chrome DevTools Console, I can't use it when I call Selenium execute_script
(See here). Is it a way that I can do this?