【问题标题】:VBA code to trigger an iframe div class element触发 iframe div 类元素的 VBA 代码
【发布时间】:2017-08-09 12:17:43
【问题描述】:

请帮我解决下面的 IE 自动化场景,

我需要一个 vba 代码来单击已放置在 iframe 内的网页标签文本(记录问题),下面给出了示例 html 代码,

<iframe name="VF304274040_1502270092884IF_1" title="Browse Categories" id="VF304274040_1502270092884IF_1" src="javascript:"<HTML></HTML>"" frameBorder="0" scrolling="auto" style="background-color: transparent; width: 100%; height: 100%; top: 0px; left: 0px;" allowTransparency="allowtransparency" onload="F(1,304274040).ol()" arviewbordercolor="null">
<head>XXXX
<body>XXXX
<div id XXXX>
.............
<div id XXXX>
......
     <div>
          <div class="categoryTitleLink">
          <label class="cursor bold category_title" id="cat-title IDHAA5V0GQBL2AN3HRTMFOSP0OLB90" level="0" category="true" categoryname="Log+an+Issue" descr="#IDHAA5V0GQBL2AN3HRTMFOSP0OLB90" jQuery15019202206560111384="9">
            ....Text - Log an Issue
</body></head>

我已经尝试使用下面的 vba 代码来解析 iframe 和它的 div 类内部文本并找到“记录问题”元素,但我无法触发它。

VBA 代码:

doc1 = IE.document.frames(1).Name
For Each div In IE.document.frames(doc1).document.getElementsByTagName("div")
        class_obj = div.innerText
        If class_obj = "Log an Issue" Then ' the text was found by this loop
            div.parentElement.Click ' this doesn't works (nothing happening)
        End If
Next div

请帮忙!!

【问题讨论】:

    标签: vba excel iframe ie-automation


    【解决方案1】:

    试试

    doc1 = IE.document.frames(1).Name
    IE.document.frames(doc1).document.getElementId("cat-title IDHAA5V0GQBL2AN3HRTMFOSP0OLB90").Click
    

    元素有一个 id,所以尝试使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-26
      • 2014-09-15
      相关资源
      最近更新 更多