As there is (according to my research) no way to catch user input with selenium, I am trying to use a JavaScript event listener.
But when I add the event listener by executing the JavaScript code, the function is automatically triggered without me (as the user) doing anything. Furthermore, there is no way to trigger the function again.
Does anyone know what the problem might be and how I could solve it? FYI: My code is in Python 3.8
Thank you in advance, Raphael
# this is a self defined function that creates a new selenium WebDriver
browser = gf.create_browser(headless=False)
browser.get("https://www.google.com")
browser.execute_script('document.getElementById("hplogo").addEventListener("mouseover",console.log("Success"))')
time.sleep(90)
The console displays "success" as soon as the script is executed, afterwards the event is never triggered again. I have tried different events (click, mouseover,...), different functions and different websites with different elemtents.