I have the following statement in my Selenium IDE
script:
I
store
javascript{window.document.getElementById('demo').innerHTML}
text
But this always fails with the error
[info] Executing: |store | javascript{window.document.getElementById('demo').innerHTML} | text | [error] Unexpected Exception: TypeError: window.document.getElementById(...) is null.
The HTML source code I am using is from w3schools. The corresponding HTML source is
<p id="demo">Click the button to change the text in this paragraph.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
}
</script>
There is no problem when I execute just
<tr>
<td>store</td>
<td>javascript{window.document.innerHTML}</td>
<td>text</td>
</tr>
but trying to retrieve an element by its id is not working. What am I missing?