title: Click on dynamically generated element after body onload using Selenium
body: <p>I'll do my best to convey my situation as the date I can give you is limited.</p>
  
  <p>There is this button inside a webpage when clicked creates a new tab whose HTML source is somewhat like below.</p>
  
  <pre><code>&lt;HTML&gt;&lt;HEAD&gt;&lt;META content="IE=5.0000" http-equiv="X-UA-Compatible"&gt;
  &lt;TITLE&gt;Report Viewer Webpage&lt;/TITLE&gt;
  &lt;META content="text/html; charset=windows-1252" http-equiv=Content-Type&gt;
  &lt;SCRIPT src="javascript1.js"&gt;&lt;/SCRIPT&gt;
  
  &lt;SCRIPT src="javascript2.js"&gt;&lt;/SCRIPT&gt;
  
  &lt;SCRIPT src="anotherJavascript.js"&gt;&lt;/SCRIPT&gt;
  &lt;/HEAD&gt;
  &lt;BODY onload="CallInit('ABC_DEFG_HIJKL_1_',''); window_onload();" onhelp=common_ShowHelp() leftMargin=0 topMargin=0 bgColor=#c6c6c6 currJsHelpVar="help_reports_viewer_dlg"&gt;
  &lt;OBJECT id=CRViewer codeBase="/viewer/activeXViewer/activexviewer.cab#Version=9,2,0,442" classid=CLSID:1123452WDUIHED:1325726GDUJBEA:12R432VD width="100%" height="99%" VIEWASTEXT&gt;
  &lt;PARAM NAME="lastProp" VALUE="500"&gt;
  &lt;!--Bunch of other params go here--&gt;
  &lt;PARAM NAME="_cx" VALUE="26987"&gt;
  &lt;SCRIPT language=VBScript&gt;
  &lt;!--Some Business Logic--&gt;
  &lt;/SCRIPT&gt;
  
  &lt;OBJECT id=ReportSource codeBase="/viewer/activeXViewer/activexviewer.cab#Version=9,2,0,442" classid=CLSID:1123452WDUIHED:1325726GDUJBEA:12R432VD width="1%" height="1%"&gt;&lt;/OBJECT&gt;
  &lt;OBJECT id=ViewHelp codeBase="/viewer/activeXViewer/activexviewer.cab#Version=9,2,0,442" classid=CLSID:1123452WDUIHED:1325726GDUJBEA:12R432VD width="1%" height="1%"&gt;&lt;/OBJECT&gt;
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>
  
  <p>And the page content look something like this:
  <img src="https://i.stack.imgur.com/2JK3p.png" alt="enter image description here"></p>
  
  <p>And of course this is a Crystal Report. </p>
  
  <p>All I want to do is click on the neat little <code>Export button</code> sitting right beside <code>Print button</code> above the text <code>preview</code>. </p>
  
  <p>And I am using Selenium to automate all this. But the problem is, selenium only works with HTML elements and I believe the buttons in the page are ActiveX controls or something else. And they are only loaded after the call to <code>&lt;Body&gt;</code> tag's <code>onLoad</code> call. </p>
  
  <p>One of the biggest constraint is that this application only works in IE and the power of IE developer tools is not enabling me to inspect the button element. IE developer tools just doesn't see those buttons as HTML elements. They don't exist to IE developer tools. I am using IE 9 by the way.</p>
  
  <p>What would help me in automating the clicking of that <code>Export</code> button ? Any javascript would help ??</p>
  
  <p>When I inspected this webpage, the first <code>&lt;Object&gt;</code> right after the <code>&lt;Body&gt;</code> is taking all the space of the view. And I think that randomly generated elements are going inside it dynamically.</p>