Button is always null even after window is loaded
<p>I am a beginner in javascript.
I am trying to click a play button which is in an embedded video player.</p>

<p>Here is the button code : </p>

<pre><code>&lt;button id="play" class="svg-button" tabindex="0" title="play" focusable="true"&gt;&lt;/button&gt;
</code></pre>

<p>I opened the console and typed this in :</p>

<pre><code>document.getElementById('play').click();
</code></pre>

<p>But I always get the same error : <code>Uncaught TypeError: Cannot read property 'click' of null</code></p>

<p>The only time it works is when I right click the play button -> inspect element, then go back to the console and re-type <code>document.getElementById('play').click();
</code>Then the video launches normally and the button is no longer null.</p>

<p>I have no idea how to solve this problem, if anyone could help me I would really appreciate it.</p>

<p>Thanks</p>