I am trying to use python selenium to change the text in a specific JS element. I started out by attempting to simply execute the script using the following:
driver.execute_script("document.querySelector('#cssSelector').textContent='{}'".format(text))
However, unfortunately, this returns null
When looking into the JS the selector is in a specific iframe so I have tried to select the iframe but this has not yet worked:
driver.execute_script('''var element=window.frames['iframe'].document.querySelector("[id='cssselector']"); element.textContent='{}'".format(text))
This code also returns undefined as it cannot find the element.
Is there a better way to do this? thanks