gpt4 book ai didi

javascript - VBA/次要 HTML/Javascript : Click a tricky hidden checkbox in a report

转载 作者:行者123 更新时间:2023-12-03 04:49:40 25 4
gpt4 key购买 nike

我每天都会收到一份工作报告,我使用 Excel 制作一个命令按钮来打开 IE,导航到报告页面,填写日期和时间详细信息,然后停止,以便我可以单击我需要勾选的这两个复选框。我希望它能够自动选中这两个复选框。这是 HTML:

<table width="100%" class="msrs-contentFrame" cellpadding="0" cellspacing="0" height="100%">
<tbody><tr>
<td valign="top" height="100%"><span><table width="100%" class="msrs-normal" cellpadding="0" cellspacing="0" height="100%">
<tbody><tr>
<td valign="top" height="100%"><div id="NavigationCorrector" style="display:none;">
<input type="hidden" name="NavigationCorrector$ScrollPosition" id="NavigationCorrector_ScrollPosition"><input type="hidden" name="NavigationCorrector$ViewState" id="NavigationCorrector_ViewState"><input type="hidden" name="NavigationCorrector$PageState" id="NavigationCorrector_PageState"><div id="NavigationCorrector_ctl00">
<input type="hidden" name="NavigationCorrector$NewViewState" id="NavigationCorrector_NewViewState">
</div>
</div><noscript>
&amp;nbsp;Your browser does not support scripts or has been configured not to allow scripts.
</noscript><span id="ctl31_ReportViewer"><div id="ctl31" onclick="if ($get('ctl31_ctl04') != null &amp;&amp; $get('ctl31_ctl04').control != null) $get('ctl31_ctl04').control.HideActiveDropDown();" onactivate="if ($get('ctl31_ctl04') != null &amp;&amp; $get('ctl31_ctl04').control != null) $get('ctl31_ctl04').control.HideActiveDropDown();" style="height: 100%; width: 100%;">
<div id="ctl31_HttpHandlerMissingErrorMessage" style="border-color:Red;border-width:2px;border-style:Solid;padding:10px;display:none;overflow:auto;font-size:.85em;">
<h2>
Report Viewer Configuration Error
</h2><p>The Report Viewer Web Control HTTP Handler has not been registered in the application's web.config file. Add &lt;add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, ReportingServicesWebUserInterface, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /&gt; to the system.web/httpHandlers section of the web.config file, or add &lt;add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, ReportingServicesWebUserInterface, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /&gt; to the system.webServer/handlers section for Internet Information Services 7 or later.</p>
</div><span id="ctl31_ctl03"><input type="hidden" name="ctl31$ctl03$ctl00" id="ctl31_ctl03_ctl00"><input type="hidden" name="ctl31$ctl03$ctl01" id="ctl31_ctl03_ctl01"></span><input type="text" name="ctl31$ctl10" id="ctl31_ctl10"><input type="hidden" name="ctl31$ctl11" id="ctl31_ctl11" value="quirks"><div id="ctl31_AsyncWait" style="background-color: white; opacity: 0.7; position: absolute; display: none; z-index: 1000;">

</div><div id="ctl31_AsyncWait_Wait" class="WaitControlBackground" style="display: none; position: absolute; z-index: 1001;">
<table height="100%">
<tbody><tr>
<td width="32px" height="32px"><img src="/ReportManager/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=10.50.4339.0&amp;Name=Microsoft.Reporting.WebForms.Icons.SpinningWheel.gif" style="height:32px;width:32px;border-width:0px;"></td><td class="WaitInfoCell"><span class="WaitText">Loading...</span><div class="CancelLinkDiv">
<a class="CancelLinkText" href="javascript:$get('ctl31_AsyncWait').control._cancelCurrentPostback();">Cancel</a>
</div></td>
</tr>
</tbody></table>
</div><input type="hidden" name="ctl31$AsyncWait$HiddenCancelField" id="ctl31_AsyncWait_HiddenCancelField" value="False"><table cellpadding="0" cellspacing="0" id="ctl31_fixedTable" style="table-layout:fixed;width:100%;height:100%;">
<tbody><tr class="MenuBarBkGnd">
<td style="display:none;width:25%;"></td><td style="display:none;width:6px;"></td><td style="width:100%;"></td>
</tr><tr id="ParametersRowctl31">
<td colspan="3"><div id="ctl31_ctl04" style="width:100%;overflow-x:auto;overflow-y:hidden;">
<div onclick="if ($get('ctl31_ctl04') != null &amp;&amp; $get('ctl31_ctl04').control != null) $get('ctl31_ctl04').control.HideActiveDropDown();" onactivate="if ($get('ctl31_ctl04') != null &amp;&amp; $get('ctl31_ctl04').control != null) $get('ctl31_ctl04').control.HideActiveDropDown();">
<table cellpadding="0" cellspacing="0" width="100%" id="ParameterTable_ctl31_ctl04" name="ParameterTable_ctl31_ctl04" class="ParametersFrame ParamsGrid MenuBarBkGnd">
<tbody><tr>
<td width="100%" height="100%"><table id="ParametersGridctl31_ctl04">
<tbody><tr isparameterrow="true">
<td class="ParamLabelCell"><span>Show Start Date From:</span></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ctl31_ctl04_ctl03">
<input name="ctl31$ctl04$ctl03$txtValue" type="text" size="30" id="ctl31_ctl04_ctl03_txtValue" class="null">
</div></td><td class="InterParamPadding"></td><td class="ParamLabelCell"><span>Show End Date To:</span></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ctl31_ctl04_ctl05">
<input name="ctl31$ctl04$ctl05$txtValue" type="text" size="30" id="ctl31_ctl04_ctl05_txtValue" class="null">
</div></td>
</tr><tr isparameterrow="true">
<td class="ParamLabelCell"><span>Show Start Hour From:</span></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ctl31_ctl04_ctl07">
<select name="ctl31$ctl04$ctl07$ddValue" id="ctl31_ctl04_ctl07_ddValue" style="width: 117px;">

<option value="1">00</option>
<option value="2">01</option>
<option value="3">02</option>
<option value="4">03</option>
<option value="5">04</option>
<option value="6">05</option>
<option value="7">06</option>
<option value="8">07</option>
<option selected="selected" value="9">08</option>
<option value="10">09</option>
<option value="11">10</option>
<option value="12">11</option>
<option value="13">12</option>
<option value="14">13</option>
<option value="15">14</option>
<option value="16">15</option>
<option value="17">16</option>
<option value="18">17</option>
<option value="19">18</option>
<option value="20">19</option>
<option value="21">20</option>
<option value="22">21</option>
<option value="23">22</option>
<option value="24">23</option>

</select>
</div></td><td class="InterParamPadding"></td><td class="ParamLabelCell"><span>Show Start Hour To:</span></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ctl31_ctl04_ctl09">
<select name="ctl31$ctl04$ctl09$ddValue" id="ctl31_ctl04_ctl09_ddValue" style="width: 117px;">

<option value="1">00</option>
<option value="2">01</option>
<option value="3">02</option>
<option value="4">03</option>
<option value="5">04</option>
<option value="6">05</option>
<option value="7">06</option>
<option value="8">07</option>
<option value="9">08</option>
<option value="10">09</option>
<option value="11">10</option>
<option value="12">11</option>
<option value="13">12</option>
<option value="14">13</option>
<option value="15">14</option>
<option value="16">15</option>
<option value="17">16</option>
<option value="18">17</option>
<option value="19">18</option>
<option value="20">19</option>
<option value="21">20</option>
<option value="22">21</option>
<option value="23">22</option>
<option selected="selected" value="24">23</option>

</select>
</div></td>
</tr><tr isparameterrow="true">
<td class="ParamLabelCell"><span>Media Type:</span></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ctl31_ctl04_ctl11">
<div onactivate="event.cancelBubble=true;" style="white-space:nowrap;">
<input name="ctl31$ctl04$ctl11$txtValue" type="text" size="28" readonly="readonly" id="ctl31_ctl04_ctl11_txtValue" class="null"><input src="/ReportManager/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=10.50.4339.0&amp;Name=Microsoft.Reporting.WebForms.Icons.MultiValueSelect.gif" name="ctl31$ctl04$ctl11$ddDropDownButton" type="image" id="ctl31_ctl04_ctl11_ddDropDownButton" alt="Select a value" title="Select a value" style="vertical-align:top;cursor:pointer;">
</div>
</div></td>
</tr>
</tbody></table></td><td width="6px"></td><td class="SubmitButtonCell"><table>
<tbody><tr>
<td><input type="submit" name="ctl31$ctl04$ctl00" value="View Report" id="ctl31_ctl04_ctl00"></td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
</div>
</div><iframe id="ctl31_ctl04_ctl11_ctl01" onclick="event.cancelBubble=true;" onactivate="event.cancelBubble=true;" style="display: none; position: absolute; z-index: 10; left: 144px; top: 110px; width: 187px; height: 97px;" src="javascript:'';" frameborder="0" title="Media Type: place holder" longdesc="Media Type: place holder" name="ctl31_ctl04_ctl11_ctl01"></iframe><div id="ctl31_ctl04_ctl11_divDropDown" onclick="event.cancelBubble=true;" onactivate="event.cancelBubble=true;" style="border-color: darkgray; border-width: 1px; border-style: solid; overflow: auto; background-color: window; display: none; position: absolute; z-index: 11; left: 144px; top: 110px; width: 187px;">
<input type="hidden" name="ctl31$ctl04$ctl11$divDropDown$HiddenIndices" id="ctl31_ctl04_ctl11_divDropDown_HiddenIndices" value="">
</div></td>
</tr><tr style="height:6px;font-size:2pt;">
<td colspan="3" class="SplitterNormal" style="padding: 0px; margin: 0px; text-align: center; cursor: default;"><div id="ctl31_ToggleParam">
<input type="image" name="ctl31$ToggleParam$img" id="ctl31_ToggleParam_img" title="Show / Hide Parameters" src="/ReportManager/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=10.50.4339.0&amp;Name=Microsoft.Reporting.WebForms.Icons.SplitterHorizCollapse.png" alt="Show / Hide Parameters" align="middle" onclick="void(0);" style="border-width:0px;cursor:pointer;"><input type="hidden" name="ctl31$ToggleParam$store" id="ctl31_ToggleParam_store"><input type="hidden" name="ctl31$ToggleParam$collapse" id="ctl31_ToggleParam_collapse" value="false">
</div></td>
</tr><tr style="display:none;">

</tr><tr>
<td style="vertical-align:top;width:25%;height:100%;display:none;"><div style="width:100%;height:100%;">
<span id="ctl31_DocMap"><div id="ctl31_ctl08" style="display:none;">
<input type="hidden" name="ctl31$ctl08$ClientClickedId" id="ctl31_ctl08_ClientClickedId">
</div></span>
</div></td><td class="SplitterNormal" style="display:none;width:4px;padding:0px;margin:0px;height:100%;vertical-align:middle;"><div id="ctl31_ctl07">
<input type="image" name="ctl31$ctl07$img" id="ctl31_ctl07_img" title="Show / Hide Document Map" src="/ReportManager/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=10.50.4339.0&amp;Name=Microsoft.Reporting.WebForms.Icons.SplitterVertCollapse.png" alt="Show / Hide Document Map" align="top" onclick="void(0);" style="border-width:0px;cursor:pointer;"><input type="hidden" name="ctl31$ctl07$store" id="ctl31_ctl07_store"><input type="hidden" name="ctl31$ctl07$collapse" id="ctl31_ctl07_collapse" value="false">
</div></td><td style="height:100%;vertical-align:top;"><div id="ctl31_ctl09" style="height:100%;width:100%;overflow:auto;position:relative;">
<div id="VisibleReportContentctl31_ctl09" style="height:100%;display:none;"></div><div id="ctl31_ctl09_ReportArea">
<div newcontenttype="Microsoft.Reporting.WebFormsClient.ReportAreaContent.None" fornonreportcontentarea="false" id="ctl31_ctl09_VisibilityState" style="visibility:none;">
<input type="hidden" name="ctl31$ctl09$VisibilityState$ctl00" value="None">
</div><input type="hidden" name="ctl31$ctl09$ScrollPosition" id="ctl31_ctl09_ScrollPosition"><span id="ctl31_ctl09_Reserved_AsyncLoadTarget"></span><div id="ctl31_ctl09_ReportControl" style="display:none;">
<span></span><input type="hidden" name="ctl31$ctl09$ReportControl$ctl02"><input type="hidden" name="ctl31$ctl09$ReportControl$ctl03"><input type="hidden" name="ctl31$ctl09$ReportControl$ctl04" id="ctl31_ctl09_ReportControl_ctl04" value="100">
</div><div id="ctl31_ctl09_NonReportContent" style="height: 100%; width: 100%; display: none;">

</div>
</div>
</div></td>
</tr>
</tbody></table>
</div></span></td>
</tr>
</tbody></table>
</span></td>
</tr>
</tbody></table>

我想点击的复选框如下:

 <input id="ctl31_ctl04_ctl11_divDropDown_ctl03" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl03" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, 'ctl31_ctl04_ctl11_divDropDown_ctl00');">

 <input id="ctl31_ctl04_ctl11_divDropDown_ctl04" type="checkbox" name="ctl31$ctl04$ctl11$divDropDown$ctl04" onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, 'ctl31_ctl04_ctl11_divDropDown_ctl00');">

但是,它们隐藏在下拉列表中

 <input src="/ReportManager/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=10.50.4339.0&amp;Name=Microsoft.Reporting.WebForms.Icons.MultiValueSelect.gif" name="ctl31$ctl04$ctl11$ddDropDownButton" type="image" id="ctl31_ctl04_ctl11_ddDropDownButton" alt="Select a value" title="Select a value" style="vertical-align:top;cursor:pointer;">

表格内

 <table id="ParametersGridctl31_ctl04">

...至少在三四个表和 div 内。有没有简单的方法来单击它/将值设置为 TRUE?

这是我正在使用的 VBA,但它不起作用,您可以看到我正在其中尝试几种不同的方法:

    Dim oCheckBox1 As Object
Set oCheckBox1 = IE.document.getElementById("ctl31_ctl04_ctl11_divDropDown_ctl03")

Dim oCheckBox2 As Object
Set oCheckBox2 = IE.document.getElementById("ctl31_ctl04_ctl11_divDropDown_ctl04")

HWNDSrc = IE.HWND
'Set IE as Active Window
SetForegroundWindow HWNDSrc

oCheckBox1.Click , True
Call IE.document.parentWindow.execScript("$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, 'ctl31_ctl04_ctl11_divDropDown_ctl00');", "JavaScript")
oCheckBox1.Checked = True
oCheckBox1.Value = True

oCheckBox2.Click , True
Call IE.document.parentWindow.execScript("$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, 'ctl31_ctl04_ctl11_divDropDown_ctl00');", "JavaScript")
oCheckBox2.Checked = True
oCheckBox2.Value = True
Dim oMediaType As Object
Set oMediaType = IE.document.getElementById("ctl31_ctl04_ctl11_txtValue")
oMediaType.Value = "[RESULT THAT COMES FROM CLICKING THE CHECKBOXES, REDACTED FOR PRIVACY]"

...然后我单击“查看报告”按钮

有什么帮助吗?

最佳答案

按照要求,这里是答案。您尝试单击的元素有一个由 JavaScript 调用的 Event

页面代码:

onclick="$get('ctl31_ctl04_ctl11').control.OnValidValueClick(this, 'ctl31_ctl04_ctl11_divDropDown_ctl00');

您需要调用该事件才能执行页面上为该按钮提供支持的代码。

简化的代码是:

 oCheckBox1.Click
oCheckBox1.FireEvent("OnClick")

关于javascript - VBA/次要 HTML/Javascript : Click a tricky hidden checkbox in a report,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42716276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com