Hi,
I am having trouble figuring out how to use vba to automate clicking a button that is located with one of a set of tabs in a web page. I used inspect element in firefox to figure out the element id for the button i want to click (which is "runscreen" but i cannot find this element id when viewing the actual web page's source code, also the button shares this element id with another button on another tab. Both buttons have the same “run” as their innertext but have different element hid’s. I can’t figure out why the element id is viewable by inspecting the button but is not viewable by selecting to view the webpage’s source code either with ie or firefox. The only part of the webpage’s code that seems to me hidden is the part that deals with the elements within the tabs. I think it may have something to do with
img src="/images/new/ajax-loader-trans.gif"
I first tried this code:
'IE.document.getElementById("runscreen").click
the vba returned an error "object required", i am guessing because the element id is not directly on the web page source code but hidden somehow
then i tried
Call IE.document.parentWindow.execScript("runscreen()", "JavaScript")
i think the page is somehow using a function when the button is clicked but i can't figure out if this is the case or not.
I have been searching all over for a solution to clicking the button but have been unable to figure it out. any help would be greatly appreciated.
here is the code i find when i use firefox to inspect the element i'm trying to click (but this code is not visible when i select view source in ie/firefox):
here is the code i find when i use firefox to inspect the element i'm trying to click (but this code is not visible when i select view source in ie/firefox):
<a id="runScreen" class="general-button general-button-green help-enabled" href="javascript: void(jsScreen.runScreen(true));" onfocus="blur();" hid="screen-rules-run">
<span>
Run
</span>
</a>
And here is more of the surrounding code (only the first line of this code which I bolded is viewable when viewing the web page source code)
<div id="screentabcontent" class="tabs-nav-content ui-corner-bottom">
<div id="freeform-cont">
<div class="vocab-ref"> … </div>
</div>
<div id="screen-criteria-section">
<div id="commonCont">
<div id="commonButtons" style="padding-bottom:4px; float:left; "> … </div>
<div style="text-align:right">
<span class="parameterTitle"> … </span>
<span class="parameterValue"> … </span>
<span style="padding-left: 10px">
<a id="runScreen" class="general-button general-button-green help-enabled" href="javascript: void(jsScreen.runScreen(true));" onfocus="blur();" hid="screen-rules-run">
<span> … </span>
</a>
</span>
<span style="padding-left: 5px"> … </span>
<span id="universeTotal" class="universe-subtotal"> … </span>
</div>
<div id="commonRules" style="clear:both; zoom: 1"> … </div>
</div>
and here is the code for the tabs that is viewable when I select view source in ie/firefox, the button i'm trying to click is in the "rules" tab which has the element id "scrtab_1" :
<div id="screentabs" style="zoom: 1;">
<div class="tabs-nav">
<table cellpadding="0" cellspacing="0" border="0"><tr>
<td class="toggle-width"><a href="javascript:void(jsScreen.toggleWide());" onfocus="blur()"><img id="toggleScrWidth" src="/images/new/width-wide.gif" width="16" height="16" border="0" title="Toggle Display Width" alt=""/></a></td>
<td ><a id="scrtab_0" class="scr-tab-link help-enabled" hid="screen-about-user" href="javascript: void(0);" onfocus="blur()">About</a></td>
<td ><a id="scrtab_5" class="scr-tab-link help-enabled" hid="screen-notes" href="javascript: void(0);" onfocus="blur()">Notes</a></td>
<td ><a id="scrtab_7" class="scr-tab-link help-enabled" hid="screen-notes" href="javascript: void(0);" onfocus="blur()">Main Settings</a></td>
<td class="on"><a id="scrtab_1" class="scr-tab-link help-enabled" hid="screen-rules" href="javascript: void(0);" onfocus="blur()">Rules</a></td>
<td ><a id="scrtab_6" class="scr-tab-link help-enabled" hid="screen-hedge" href="javascript: void(0);" onfocus="blur()">Hedge Rules</a></td>
<td ><a id="scrtab_2" class="scr-tab-link help-enabled" hid="screen-results" href="javascript: void(0);" onfocus="blur()">Results</a></td>
<td ><a id="scrtab_3" class="scr-tab-link help-enabled" hid="screen-backtest" href="javascript: void(0);" onfocus="blur()">Backtest</a></td>
<td ><a id="scrtab_4" class="scr-tab-link help-enabled" hid="screen-advancedbacktest" href="javascript: void(0);" onfocus="blur()">Advanced Backtest</a></td>
</tr></table>
</div>
<div id="screentabcontent" class="tabs-nav-content ui-corner-bottom"><div align="center"><img src="/images/new/ajax-loader-trans.gif" alt="loading"></div></div>
</div>
</div>
</div>
</center>
</div>
I am having trouble figuring out how to use vba to automate clicking a button that is located with one of a set of tabs in a web page. I used inspect element in firefox to figure out the element id for the button i want to click (which is "runscreen" but i cannot find this element id when viewing the actual web page's source code, also the button shares this element id with another button on another tab. Both buttons have the same “run” as their innertext but have different element hid’s. I can’t figure out why the element id is viewable by inspecting the button but is not viewable by selecting to view the webpage’s source code either with ie or firefox. The only part of the webpage’s code that seems to me hidden is the part that deals with the elements within the tabs. I think it may have something to do with
img src="/images/new/ajax-loader-trans.gif"
I first tried this code:
'IE.document.getElementById("runscreen").click
the vba returned an error "object required", i am guessing because the element id is not directly on the web page source code but hidden somehow
then i tried
Call IE.document.parentWindow.execScript("runscreen()", "JavaScript")
i think the page is somehow using a function when the button is clicked but i can't figure out if this is the case or not.
I have been searching all over for a solution to clicking the button but have been unable to figure it out. any help would be greatly appreciated.
here is the code i find when i use firefox to inspect the element i'm trying to click (but this code is not visible when i select view source in ie/firefox):
here is the code i find when i use firefox to inspect the element i'm trying to click (but this code is not visible when i select view source in ie/firefox):
<a id="runScreen" class="general-button general-button-green help-enabled" href="javascript: void(jsScreen.runScreen(true));" onfocus="blur();" hid="screen-rules-run">
<span>
Run
</span>
</a>
And here is more of the surrounding code (only the first line of this code which I bolded is viewable when viewing the web page source code)
<div id="screentabcontent" class="tabs-nav-content ui-corner-bottom">
<div id="freeform-cont">
<div class="vocab-ref"> … </div>
</div>
<div id="screen-criteria-section">
<div id="commonCont">
<div id="commonButtons" style="padding-bottom:4px; float:left; "> … </div>
<div style="text-align:right">
<span class="parameterTitle"> … </span>
<span class="parameterValue"> … </span>
<span style="padding-left: 10px">
<a id="runScreen" class="general-button general-button-green help-enabled" href="javascript: void(jsScreen.runScreen(true));" onfocus="blur();" hid="screen-rules-run">
<span> … </span>
</a>
</span>
<span style="padding-left: 5px"> … </span>
<span id="universeTotal" class="universe-subtotal"> … </span>
</div>
<div id="commonRules" style="clear:both; zoom: 1"> … </div>
</div>
and here is the code for the tabs that is viewable when I select view source in ie/firefox, the button i'm trying to click is in the "rules" tab which has the element id "scrtab_1" :
<div id="screentabs" style="zoom: 1;">
<div class="tabs-nav">
<table cellpadding="0" cellspacing="0" border="0"><tr>
<td class="toggle-width"><a href="javascript:void(jsScreen.toggleWide());" onfocus="blur()"><img id="toggleScrWidth" src="/images/new/width-wide.gif" width="16" height="16" border="0" title="Toggle Display Width" alt=""/></a></td>
<td ><a id="scrtab_0" class="scr-tab-link help-enabled" hid="screen-about-user" href="javascript: void(0);" onfocus="blur()">About</a></td>
<td ><a id="scrtab_5" class="scr-tab-link help-enabled" hid="screen-notes" href="javascript: void(0);" onfocus="blur()">Notes</a></td>
<td ><a id="scrtab_7" class="scr-tab-link help-enabled" hid="screen-notes" href="javascript: void(0);" onfocus="blur()">Main Settings</a></td>
<td class="on"><a id="scrtab_1" class="scr-tab-link help-enabled" hid="screen-rules" href="javascript: void(0);" onfocus="blur()">Rules</a></td>
<td ><a id="scrtab_6" class="scr-tab-link help-enabled" hid="screen-hedge" href="javascript: void(0);" onfocus="blur()">Hedge Rules</a></td>
<td ><a id="scrtab_2" class="scr-tab-link help-enabled" hid="screen-results" href="javascript: void(0);" onfocus="blur()">Results</a></td>
<td ><a id="scrtab_3" class="scr-tab-link help-enabled" hid="screen-backtest" href="javascript: void(0);" onfocus="blur()">Backtest</a></td>
<td ><a id="scrtab_4" class="scr-tab-link help-enabled" hid="screen-advancedbacktest" href="javascript: void(0);" onfocus="blur()">Advanced Backtest</a></td>
</tr></table>
</div>
<div id="screentabcontent" class="tabs-nav-content ui-corner-bottom"><div align="center"><img src="/images/new/ajax-loader-trans.gif" alt="loading"></div></div>
</div>
</div>
</div>
</center>
</div>
Last edited: