Retreive a javascript variable from selenium (mutationobserver) to python

21 Views Asked by At

I would like to know if it is possible to track changes from a tchat room, like new messages ..., with selenium and mutationobserver

For example, is it possible to send the variable "returntext" to python everytime a mutation is observed?

driver.execute_script("""
        
var ourObserver = new MutationObserver(function() {
    var returntext = "example"
});

ourObserver.observe(document.querySelector(".testclass"), {
    subtree: true,
    childList: true
});            
                             
""")
0

There are 0 best solutions below