html - Internet Explorer - 在多页中选择选项卡
问题描述
背景:
对于一个项目,我试图控制一个页面及其元素。我对通过 VBA 控制网页非常陌生,但设法使用登录凭据,单击一些中间窗口和控件以最终进入感兴趣的主页:Ultimo。不幸的是,我无法分享 URL 和登录凭据,所以我很抱歉只粘贴了一些HTML
和一个大屏幕截图。
问题:
登录并导航到这个特定菜单后,我卡在了一个多选项卡框架上。以下是HTML
我通过的.document.body.innerHTML
<div class="c-viewport c-container c-component" id="viewport">
<div class="c-maincontainer c-container c-component l-vbox" id="maincontainer">
<div class="maintoolbar c-maintoolbar c-toolbar c-container c-component l-hbox" id="maintoolbar" style="height: 50px; line-height: 50px;">
<div class="mainmenuicon c-container c-component l-flow" id="container14" style="width: 32px;"><button tabindex="-1" class="c-button c-component c-button-appearance-icon c-button-large icon icon-menu1" id="button17" type="button"></button></div>
<div class="logo clickable c-container c-component l-flow" id="container20"><img title="Logo" class="c-image c-component" id="image23" src="ultimo.framework.web/assets/images/system/ultimo-logo-small.png"></div>
<div class="history c-history c-toolbar c-container c-component l-hbox" id="history" style="height: 50px; line-height: 50px;">
<button tabindex="-1" class="c-button c-component c-button-appearance-icon c-button-large icon icon-history-previous" id="button28" type="button"></button><button tabindex="-1" disabled="" class="c-button c-component c-button-appearance-icon c-button-large icon icon-history-next" id="button31" type="button"></button>
<div class="c-menubutton c-container c-component l-flow" id="menubutton34"><button tabindex="-1" class="c-button c-component c-button-appearance-icon c-button-large icon icon-arrow-dropdown" id="button37" style="height: 100%;" type="button"></button></div>
</div>
<span class="c-separator c-component" id="separator64"></span><button tabindex="-1" class="c-button c-component c-button-appearance-icon c-button-large icon icon-home" id="button67" type="button"></button><span class="c-template c-component l-template" id="header"><span class="breadcrumbs"><span class="icon icon-breadcrumb-item-separator"></span><span>Decompositie per niveau</span><span class="icon icon-breadcrumb-item-separator"></span><span>Objecten</span></span>
</span>
<div class="c-fill c-component" id="fill72" style="flex:1 1 1px;"></div>
<div class="c-menubutton c-container c-component l-flow" id="settingsMenu"><button tabindex="-1" class="c-button c-component c-button-appearance-icon c-button-large icon icon-gear" id="button77" style="height: 100%;" type="button"></button></div>
<div class="c-menubutton c-container c-component l-flow" id="recordPackage" style="display: none;"></div>
<button tabindex="-1" class="c-button c-component c-button-appearance-icon c-button-large icon icon-search" id="search" type="button"></button>
<div class="c-menubutton c-container c-component l-flow" id="menuhelp"><button tabindex="-1" class="c-button c-component c-button-appearance-icon c-button-large icon icon-help" id="button156" style="height: 100%;" type="button"></button></div>
<button tabindex="-1" class="c-badgebutton c-button c-component c-badgebutton-appearance-icon c-badgebutton-large icon icon-notification" id="notifications" type="button"></button><span class="c-separator c-component" id="separator199" style="display: none;"></span><span class="c-template c-component l-template" id="template202" style="display: none;"><span class="dtap dtap-production">Production</span>
</span><span class="c-separator c-component" id="separator205"></span><span class="welcome literal c-literal c-component" id="literal208">here was my username</span><span class="c-separator c-component" id="separator211"></span><button tabindex="-1" class="c-button c-component c-button-appearance-icon c-button-large icon icon-logout" id="button214" type="button"></button>
</div>
<div class="c-container c-component l-hbox" id="container217" style="left: 0px; top: 50px; right: 0px; bottom: 0px; position: absolute;">
<div class="c-mainmenubar c-container c-component l-flow" id="mainmenubar224" style="display: none;">
<div title="Mijn Ultimo" class="item" data-index="0"><i class="app-icon-user"></i></div>
<div title="Werkprocessen" class="item" data-index="1"><i class="app-icon-infra"></i></div>
<div title="Beheer en onderhoud" class="item" data-index="2"><i class="app-icon-selfservice-requestrebuilding"></i></div>
<div title="Industriele automatisering" class="item" data-index="3"><i class="app-icon-processfunction-configuration"></i></div>
<div title="De balie registraties" class="item" data-index="4"><i class="app-icon-job-fleet"></i></div>
<div title="Verkenners" class="item" data-index="5"><i class="app-icon-module-explorers"></i></div>
<div title="Decompositie per niveau" class="item" data-index="6"><i class="app-icon-processfunction-object"></i></div>
<div title="Organisatie" class="item" data-index="7"><i class="app-icon-building"></i></div>
<div title="Contracten" class="item" data-index="8"><i class="app-icon-servicecontract-infra"></i></div>
<div title="Programmering" class="item" data-index="9"><i class="app-icon-cost"></i></div>
<div title="Arbeidsmiddelen" class="item" data-index="10"><i class="app-icon-inspection"></i></div>
<div title="Functioneelbeheer" class="item" data-index="11"><i class="app-icon-job-servicerequest"></i></div>
<div title="Geo-informatie" class="item" data-index="12"><i class="app-icon-address"></i></div>
<div title="Gebouw" class="item" data-index="13"><i class="app-icon-building-standard"></i></div>
<div title="Inkoop" class="item" data-index="14"><i class="app-icon-purchase"></i></div>
<div title="Magazijn" class="item" data-index="15"><i class="app-icon-warehouse-standard"></i></div>
<div title="HSE" class="item" data-index="16"><i class="app-icon-hse"></i></div>
<div title="FIT" class="item" data-index="17"><i class="app-icon-pmworkorder"></i></div>
<div title="Algemeen" class="item" data-index="18"><i class="app-icon-general"></i></div>
<div title="Stamgegevens" class="item" data-index="19"><i class="app-icon-basic"></i></div>
<div title="Statische overzichten " class="item" data-index="20"><i class="app-icon-report"></i></div>
<div title="Instellingen" class="item" data-index="21"><i class="app-icon-settings"></i></div>
<div title="TD" class="item" data-index="22"><i class="app-icon-technicalservice"></i></div>
</div>
<div tabindex="0" class="c-mainmenu c-menu c-treepanel c-panel c-container c-component l-vbox has-arrows" id="mainmenu">
<div class="c-panelheader c-toolbar c-container c-component l-hbox" id="panelheader229" style="display: none;"></div>
<div class="panelbody c-container c-component l-flow" id="container241">
<table class="treenode is-toplevel is-expanded is-hidden">
<tbody>
<tr title="">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"></td>
</tr>
</tbody>
</table>
<table class="treenode is-toplevel is-expanded">
<tbody>
<tr title="Decompositie per niveau">
<td class="line pad"><i class="app-icon-processfunction-object"></i></td>
<td class="line first"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner">Decompositie per niveau</td>
</tr>
</tbody>
</table>
<table class="treenode is-leaf">
<tbody>
<tr title="Hoofdsysteem">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line first"></td>
<td class="line"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"><a tabindex="-1" href="main.aspx#screen/24d7a953-c8a4-4b8a-cc91-28d551c8c033">Hoofdsysteem</a></td>
</tr>
</tbody>
</table>
<table class="treenode is-leaf">
<tbody>
<tr title="Systeem">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line first"></td>
<td class="line"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"><a tabindex="-1" href="main.aspx#screen/052769b9-757c-4a3c-d7da-6cd2f20c389e">Systeem</a></td>
</tr>
</tbody>
</table>
<table class="treenode is-leaf">
<tbody>
<tr title="Systeemdeel">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line first"></td>
<td class="line"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"><a tabindex="-1" href="main.aspx#screen/a129239c-58d2-4d9d-8a95-c543aff824f2">Systeemdeel</a></td>
</tr>
</tbody>
</table>
<table class="treenode is-leaf">
<tbody>
<tr title="Complexen">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line first"></td>
<td class="line"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"><a tabindex="-1" href="main.aspx#screen/58ab5a6e-e1ad-41d2-a992-3ceab120644a">Complexen</a></td>
</tr>
</tbody>
</table>
<table class="treenode is-leaf is-selected is-highlight">
<tbody>
<tr title="Objecten">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line first"></td>
<td class="line"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"><a tabindex="-1" href="main.aspx#screen/fefbf433-378d-4bd4-ad8d-e395c22100cf">Objecten</a></td>
</tr>
</tbody>
</table>
<table class="treenode is-leaf">
<tbody>
<tr title="Installaties">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line first"></td>
<td class="line"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"><a tabindex="-1" href="main.aspx#screen/2fd711d4-f0d8-41aa-c3b8-96d204d756ee">Installaties</a></td>
</tr>
</tbody>
</table>
<table class="treenode is-leaf">
<tbody>
<tr title="Elementen">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line first"></td>
<td class="line"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"><a tabindex="-1" href="main.aspx#screen/7aa389ad-73ce-4f1d-b7c1-fe67ce7e5907">Elementen</a></td>
</tr>
</tbody>
</table>
<table class="treenode is-leaf">
<tbody>
<tr title="Onderdelen">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line first"></td>
<td class="line"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"><a tabindex="-1" href="main.aspx#screen/f88c0a48-c29a-4e14-96c4-feb20c9e12ba">Onderdelen</a></td>
</tr>
</tbody>
</table>
<table class="treenode is-leaf">
<tbody>
<tr title="Bouwdelen">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line first"></td>
<td class="line"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"><a tabindex="-1" href="main.aspx#screen/8c24ae05-07a0-4446-a625-292dcb2359a1">Bouwdelen</a></td>
</tr>
</tbody>
</table>
<table class="treenode is-leaf">
<tbody>
<tr title="Componenten">
<td class="line pad"><i class="app-icon-"></i></td>
<td class="line first"></td>
<td class="line"></td>
<td class="line">
<div class="toggleimage"></div>
</td>
<td class="inner"><a tabindex="-1" href="main.aspx#screen/5663968c-ede6-4045-8d90-7274ed812cb6">Componenten</a></td>
</tr>
</tbody>
</table>
这帮助我使用如下代码将左侧的菜单导航到“Decompositie per niveau”>“Objecten”:
For Each oHTML_Element In .document.getElementsByTagName("td")
If oHTML_Element.innerHTML = "Decompositie per niveau" Then oHTML_Element.Click
Next
For Each oHTML_Element In .document.getElementsByTagName("a")
If oHTML_Element.innerHTML = "Objecten" Then oHTML_Element.Click
Next
尽管上面成功打开了有问题的多选项卡视图,但在检查元素(突出显示的选项卡)时,我不再看到/识别我的HTML
了。查看我IsObject(.document.getElementById("IdInputTab"))
尝试过的代码,但返回FALSE
。我在下面的屏幕截图中强调了我认为我应该提到的内容。选择正确的选项卡时,“标题”更改为“ clstabpage是选择的”。还有另一个选项卡(位于突出显示的选项卡的正下方),该选项卡随后被隐藏并显示为空的标题。
问题:
我尝试了多项发现:
但无济于事。在我可以按照通过 ID/名称查找其他元素的逻辑的情况下,我无法理解如何在此窗口中“单击”正确的选项卡(以及它的底层元素)。
编辑根据评论:
例如,以下(当添加到上述工作步骤时)将返回错误 424 Object required:
Application.Wait Now() + TimeValue("00:00:30")
Range("C1").Value = .document.querySelector("[id='iframe258']").contentDocument.body.innerHTML
或者:
Debug.Print IsObject(.document.getElementsByTagName("iframe")(0).contentDocument.getElementById("IdInputTab"))
将返回False
但是,我确实通过以下方式收到了HTML
内文:.document.getElementsByTagName("iframe")(0).contentDocument.body.innerHTML
。由于问题的主体不再支持字符(我希望尽可能完整)。特此链接到记事本文件。
有任何想法吗?
解决方案
推荐阅读
- c++ - 在 C++ 中从 'char' 更改字符
- antd - 使用新安装的 antd 进行新的 create-react-app 安装会导致默认主题设置为黑底黑字的部分
- c# - 如何在发布管道中更改 Appsettings 和 Config 信息
- mysql - 查询 COUNT(field) 不考虑 id
- typescript - 设置 tsconfig.json 目标会破坏路径
- android - 如何在 Kotlin 中打开菜单项选择的新页面?
- excel - 在vba中的大写字母前放置一个空格
- database - 有没有办法为 SQL 查询等迭代器优化 Rust 过滤器?
- angular - 如何在另一个formArray中禁用反应式表单控件
- search - 在 MarkLogic java API 中提取属性并获取结果