我在下拉菜单中有一些项目,我想选择其中一项。通过搜索HTML中的options
标记,我可以在下拉列表中选择它,但是每个项目均未加载的预设。我认为这是因为我没有使用select
标签“选择”该项目。有人知道如何解决吗?
Set objCollection = IE.Document.getElementsByTagName("select")
For Each opt In IE.Document.getElementsByTagName("option")
If opt.innerText = "Tracker Availability" Then
Debug.Print "found it"
opt.Selected = True
Exit For
End If
Next opt
HTML:
<select style="width: 100px; height: 33px; margin-left: 5px; border-radius: 2px;" ng-model="$ctrl.selectedScratchPad" ng-options="s.name for s in $ctrl.scratchPads track by s.name" ng-change="$ctrl.scratchPadSelected($ctrl.selectedScratchPad)" class="ng-pristine ng-valid ng-empty ng-touched"><!-- ngIf: $ctrl.selectedScratchPad === null --><option ng-if="$ctrl.selectedScratchPad === null" value="" disabled="disabled" selected="selected" class="ng-binding ng-scope">Select Export</option><!-- end ngIf: $ctrl.selectedScratchPad === null --><option label="G&T" value="G&T">G&T</option><option label="Relatório semanal" value="Relatório semanal">Relatório semanal</option><option label="CBs current" value="CBs current">CBs current</option><option label="Tracker Availability" value="Tracker Availability">Tracker Availability</option><option label="INV 5-1 Trackers target" value="INV 5-1 Trackers target">INV 5-1 Trackers target</option><option label="INV 5-1 Trackers current" value="INV 5-1 Trackers current">INV 5-1 Trackers current</option><option label="INV 5-1 Trackers availability" value="INV 5-1 Trackers availability">INV 5-1 Trackers availability</option><option label="PVSyst Input" value="PVSyst Input">PVSyst Input</option></select>
Edit1:这是两张图片,它们显示了我未加载预设的含义:
Pic-1:当opt.Selected = True时 图片2:当我通过选择所需内容手动更改下拉菜单值时