鼠标移动动态Div的网页报废

时间:2018-04-10 15:05:34

标签: vba

单击“调整”后,我无法导航。我想从Adjust-> Extended-> EMEA-> FAEM Ext App导航。经过调查,我发现没有点击Extended和EMEA,它只是一个鼠标导航。当我在这两个导航上移动我的鼠标时,会有动态Div在Web内容中创建。之后我可以用我的代码直接点击FAEM Ext App。我该如何处理这种动态Web内容。目前我正在使用sendkeys。Navigation Image

    Dim IE As New SHDocVw.InternetExplorer
    Dim HTMLdoc As MSHTML.HTMLDocument
    Dim HTMLinput As MSHTML.IHTMLElement
    Dim HTMLAs As MSHTML.IHTMLElementCollection
    Dim HTMLa As MSHTML.IHTMLElement
    Dim firstlink As MSHTML.IHTMLElement
    Dim firstlinks As MSHTML.IHTMLElementCollection
    Dim secondlink As MSHTML.IHTMLElement
    Dim secondlinks As MSHTML.IHTMLElementCollection


    Set IE = New InternetExplorerMedium

    IE.Visible = True

    IE.navigate MyURL

    Do While IE.ReadyState <> READYSTATE_COMPLETE
    Loop

    Set HTMLdoc = IE.document


    Set HTMLinput = HTMLdoc.getElementById("USER")
    HTMLinput.Value = "Jk9091"

    Set HTMLinput = HTMLdoc.getElementById("PASSWORD")
    HTMLinput.Value = "abc@123"

    Set HTMLAs = HTMLdoc.getElementsByClassName("ButtonSm")

    For Each HTMLa In HTMLAs
       If HTMLa.className = "ButtonSm" Then
         HTMLa.Click
    Exit For
        End If
    Next HTMLa

    Application.Wait (Now + TimeValue("00:00:10"))

    Set HTMLdoc = IE.document
    Set firstlinks = HTMLdoc.getElementsByTagName("a")
    Application.Wait (Now + TimeValue("00:00:02"))

    For Each firstlink In firstlinks
               If InStr(firstlink.innerText, "Adjust") > 0 Then
                firstlink.Click
                Exit For
            End If
     Next firstlink

    Application.Wait (Now + TimeValue("00:00:02"))

    SendKeys "{DOWN 3}", True
    Application.Wait (Now + TimeValue("00:00:1"))
    SendKeys "{RIGHT}", True
    Application.Wait (Now + TimeValue("00:00:1"))
    SendKeys "{DOWN}", True
    Application.Wait (Now + TimeValue("00:00:1"))
    SendKeys "{RIGHT}", True
    Application.Wait (Now + TimeValue("00:00:1"))


    Set HTMLdoc = IE.document
Set secondlinks = HTMLdoc.getElementsByTagName("a")

     For Each secondlink In secondlinks
     Debug.Print secondlink.className, secondlink.innerText
               If InStr(secondlink.innerText, "FAEM Ext App") > 0 Then
                secondlink.Click
                Exit For
            End If
    Next secondlink

HTML代码:

&#13;
&#13;
<div class="x-component x-box-item x-component-default x-menu-item" id="portal_navitem-1092" style="margin: 0px; left: 0px; top: 48px; width: 139px; right: auto;
    ">
  <a class="x-menu-item-link " id="portal_navitem-1092-itemEl" role="presentation" hidefocus="true" href="#" target="portal_center_frame" unselectable="on">
    <span class="x-menu-item-text x-menu-item-indent x-menu-item-indent-right-arrow" id="portal_navitem-1092-textEl" unselectable="on">Extended</span>
    <div class="x-menu-item-icon portal-dashboard " id="portal_navitem-1092-iconEl" role="presentation"></div>
    <div class="x-menu-item-arrow" id="portal_navitem-1092-arrowEl" role="presentation"></div>
  </a>
</div>
&#13;
&#13;
&#13;

移动我的sendkeys后,我得到的HTML代码是

&#13;
&#13;
<div class="x-component x-box-item x-component-default x-menu-item" id="portal_navitem-1098" style="margin: 0px; left: 0px; top: 24px; width: 120px; right: auto;">
<a class="x-menu-item-link " id="portal_navitem-1098-itemEl" role="presentation" hidefocus="true" href="#" target="portal_center_frame" unselectable="on">
<span class="x-menu-item-text x-menu-item-indent x-menu-item-indent-right-arrow" id="portal_navitem-1098-textEl" unselectable="on">EMEA</span>
<div class="x-menu-item-icon portal-dashboard " id="portal_navitem-1098-iconEl" role="presentation"></div>
<div class="x-menu-item-arrow" id="portal_navitem-1098-arrowEl" role="presentation"></div>
</a>
</div>
&#13;
&#13;
&#13;

&#13;
&#13;
<div class="x-box-inner x-vertical-box-overflow-body" id="menu-1099-innerCt" role="presentation" style="width: 120px; height: 48px;">
  <div class="x-menu-icon-separator" id="ext-gen1224" role="presentation">&nbsp;</div>
  <div class="x-box-target" id="menu-1099-targetEl" role="presentation" style="width: 120px;">
    <div class="x-component x-box-item x-component-default x-menu-item" id="portal_navitem-1100" style="margin: 0px; left: 0px; top: 0px; width: 120px; right: auto;"><a class="x-menu-item-link " id="portal_navitem-1100-itemEl" role="presentation" hidefocus="true" href="#" target="portal_center_frame" unselectable="on"><span class="x-menu-item-text x-menu-item-indent" id="portal_navitem-1100-textEl" unselectable="on">FAEM Ext App</span><div class="x-menu-item-icon portal-dashboard " id="portal_navitem-1100-iconEl" role="presentation"></div></a></div>
    <div
      class="x-component x-box-item x-component-default x-menu-item" id="portal_navitem-1101" style="margin: 0px; left: 0px; top: 24px; width: 120px; right: auto;"><a class="x-menu-item-link " id="portal_navitem-1101-itemEl" role="presentation" hidefocus="true" href="#" target="portal_center_frame" unselectable="on"><span class="x-menu-item-text x-menu-item-indent" id="portal_navitem-1101-textEl" unselectable="on">Approve</span><div class="x-menu-item-icon portal-dashboard " id="portal_navitem-1101-iconEl" role="presentation"></div></a></div>
</div>
</div>
&#13;
&#13;
&#13;

我右键点击了FAEM Ext App - &gt;检查元素 - &gt;然后在右侧有一个选项,如Stysles,Computed,Layout,Events - &gt;我点击了活动 - &gt;有几个名为click的列表:n,Keydown:n,mousedown:n,mouseenter:n,mouseover:n,mouseleave:n。 - &GT;我点击鼠标悬停 - &gt;它将我引导到调试器部分的函数&#34; n&#34;从那里复制几行代码。希望这可以帮助。如果需要其他任何事情,请告诉我。

&#13;
&#13;
n = function(u, s) {
  var t;
  if (!q) {
    t = ["if(!" + Ext.name + ") {return;}"];
    if (l.buffer || l.delay || l.freezeEvent) {
      if (l.freezeEvent) {
        t.push("e = X.EventObject.setEvent(e);")
      }
      t.push("e = new X.EventObjectImpl(e, " + (l.freezeEvent ? "true" : "false") + ");")
    } else {
      t.push("e = X.EventObject.setEvent(e);")
    }
    if (l.delegate) {
      t.push('var result, t = e.getTarget("' + (l.delegate + "").replace(a, "\\\\") + '", this);');
      t.push("if(!t) {return;}")
    } else {
      t.push("var t = e.target, result;")
    }
    if (l.target) {
      t.push("if(e.target !== options.target) {return;}")
    }
    if (l.stopEvent) {
      t.push("e.stopEvent();")
    } else {
      if (l.preventDefault) {
        t.push("e.preventDefault();")
      }
      if (l.stopPropagation) {
        t.push("e.stopPropagation();")
      }
    }
    if (l.normalized === false) {
      t.push("e = e.browserEvent;")
    }
    if (l.buffer) {
      t.push("(wrap.task && clearTimeout(wrap.task));");
      t.push("wrap.task = setTimeout(function() {")
    }
    if (l.delay) {
      t.push("wrap.tasks = wrap.tasks || [];");
      t.push("wrap.tasks.push(setTimeout(function() {")
    }
    t.push("result = fn.call(scope || dom, e, t, options);");
    if (l.single) {
      t.push("evtMgr.removeListener(dom, ename, fn, scope);")
    }
    if (m !== "mousemove" && m !== "unload") {
      t.push("if (evtMgr.idleEvent.listeners.length) {");
      t.push("evtMgr.idleEvent.fire();");
      t.push("}")
    }
    if (l.delay) {
      t.push("}, " + l.delay + "));")
    }
    if (l.buffer) {
      t.push("}, " + l.buffer + ");")
    }
    t.push("return result;");
    q = Ext.cacheableFunctionFactory("e", "options", "fn", "scope", "ename", "dom", "wrap", "args", "X", "evtMgr", t.join("\n"))
  }
  return q.call(r, u, l, p, o, m, r, n, s, Ext, b)
};
return n
}, getEventCache: function(n) {
var m, l, o;
if (!n) {
  return []
}
if (n.$cache) {
  m = n.$cache
} else {
  if (typeof n === "string") {
    o = n
  } else {
    o = b.getId(n)
  }
  m = Ext.cache[o]
}
l = m.events || (m.events = {});
return l
}, getEventListenerCache: function(n, l) {
var m = b.getEventCache(n);
return m[l] || (m[l] = [])
}, cloneEventListenerCache: function(o, l) {
var n = b.getEventCache(o),
  m;
if (n[l]) {
  m = n[l].slice(0)
} else {
  m = []
}
n[l] = m;
return m
}, mouseLeaveRe: /(mouseout|mouseleave)/, mouseEnterRe: /(mouseover|mouseenter)/, stopEvent: function(l) {
b.stopPropagation(l);
b.preventDefault(l)
}, stopPropagation: function(l) {
l = l.browserEvent || l;
if (l.stopPropagation) {
  l.stopPropagation()
} else {
  l.cancelBubble = true
}
}, preventDefault: function(l) {
l = l.browserEvent || l;
if (l.preventDefault) {
  l.preventDefault()
} else {
  l.returnValue = false;
  try {
    if (l.ctrlKey || l.keyCode > 111 && l.keyCode < 124) {
      l.keyCode = -1
    }
  } catch (m) {}
}
}, getRelatedTarget: function(l) {
l = l.browserEvent || l;
var m = l.relatedTarget;
if (!m) {
  if (b.mouseLeaveRe.test(l.type)) {
    m = l.toElement
  } else {
    if (b.mouseEnterRe.test(l.type)) {
      m = l.fromElement
    }
  }
}
return b.resolveTextNode(m)
}, getPageX: function(l) {
return b.getPageXY(l)[0]
}, getPageY: function(l) {
return b.getPageXY(l)[1]
}, getPageXY: function(n) {
n = n.browserEvent || n;
var m = n.pageX,
  p = n.pageY,
  o = j.documentElement,
  l = j.body;
if (!m && m !== 0) {
  m = n.clientX + (o && o.scrollLeft || l && l.scrollLeft || 0) - (o && o.clientLeft || l && l.clientLeft || 0);
  p = n.clientY + (o && o.scrollTop || l && l.scrollTop || 0) - (o && o.clientTop || l && l.clientTop || 0)
}
return [m, p]
}, getTarget: function(l) {
l = l.browserEvent || l;
return b.resolveTextNode(l.target || l.srcElement)
}, resolveTextNode: Ext.isGecko ? function(m) {
if (m) {
  var l = HTMLElement.prototype.toString.call(m);
  if (l !== "[xpconnect wrapped native prototype]" && l !== "[object XULElement]") {
    return m.nodeType == 3 ? m.parentNode : m
  }
}
} : function(l) {
return l && l.nodeType == 3 ? l.parentNode : l
}, curWidth: 0, curHeight: 0, onWindowResize: function(o, n, m) {
var l = b.resizeEvent;
if (!l) {
  b.resizeEvent = l = new Ext.util.Event();
  b.on(e, "resize", b.fireResize, null, {
    buffer: 100
  })
}
l.addListener(o, n, m)
}, fireResize: function() {
var l = Ext.Element.getViewWidth(),
  m = Ext.Element.getViewHeight();
if (b.curHeight != m || b.curWidth != l) {
  b.curHeight = m;
  b.curWidth = l;
  b.resizeEvent.fire(l, m)
}
}, removeResizeListener: function(n, m) {
var l = b.resizeEvent;
if (l) {
  l.removeListener(n, m)
}
}, onWindowUnload: function(o, n, m) {
var l = b.unloadEvent;
if (!l) {
  b.unloadEvent = l = new Ext.util.Event();
  b.addListener(e, "unload", b.fireUnload)
}
if (o) {
  l.addListener(o, n, m)
}
}, fireUnload: function() {
try {
  j = e = undefined;
  var q, m, o, n, l;
  b.unloadEvent.fire();
  if (Ext.isGecko3) {
    q = Ext.ComponentQuery.query("gridview");
    m = 0;
    o = q.length;
    for (; m < o; m++) {
      q[m].scrollToTop()
    }
  }
  l = Ext.cache;
  for (n in l) {
    if (l.hasOwnProperty(n)) {
      b.removeAll(n)
    }
  }
} catch (p) {}
}, removeUnloadListener: function(n, m) {
var l = b.unloadEvent;
if (l) {
  l.removeListener(n, m)
}
}, useKeyDown: Ext.isWebKit ? parseInt(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1], 10) >= 525 : !((Ext.isGecko && !Ext.isWindows) || (Ext.isOpera && Ext.operaVersion < 12)), getKeyEvent: function() {
return b.useKeyDown ? "keydown" : "keypress"
}
});
if (!h && document.attachEvent) {
  Ext.apply(b, {
    pollScroll: function() {
      var l = true;
      try {
        document.documentElement.doScroll("left")
      } catch (m) {
        l = false
      }
      if (l && document.body) {
        b.onReadyEvent({
          type: "doScroll"
        })
      } else {
        b.scrollTimeout = setTimeout(b.pollScroll, 20)
      }
      return l
    },
    scrollTimeout: null,
    readyStatesRe: /complete/i,
    checkReadyState: function() {
      var l = document.readyState;
      if (b.readyStatesRe.test(l)) {
        b.onReadyEvent({
          type: l
        })
      }
    },
    bindReadyEvent: function() {
      var l = true;
      if (b.hasBoundOnReady) {
        return
      }
      try {
        l = window.frameElement === undefined
      } catch (m) {
        l = false
      }
      if (!l || !j.documentElement.doScroll) {
        b.pollScroll = Ext.emptyFn
      }
      if (b.pollScroll() === true) {
        return
      }
      if (j.readyState == "complete") {
        b.onReadyEvent({
          type: "already " + (j.readyState || "body")
        })
      } else {
        j.attachEvent("onreadystatechange", b.checkReadyState);
        window.attachEvent("onload", b.onReadyEvent);
        b.hasBoundOnReady = true
      }
    },
    onReadyEvent: function(l) {
      if (l && l.type) {
        b.onReadyChain.push(l.type)
      }
      if (b.hasBoundOnReady) {
        document.detachEvent("onreadystatechange", b.checkReadyState);
        window.detachEvent("onload", b.onReadyEvent)
      }
      if (Ext.isNumber(b.scrollTimeout)) {
        clearTimeout(b.scrollTimeout);
        delete b.scrollTimeout
      }
      if (!Ext.isReady) {
        b.fireDocReady()
      }
    },
    onReadyChain: []
  })
}
Ext.onReady = function(n, m, l) {
  Ext.Loader.onReady(n, m, true, l)
};
Ext.onDocumentReady = b.onDocumentReady;
b.on = b.addListener;
b.un = b.removeListener;
Ext.onReady(g)
}();
(Ext.cmd.derive("Ext.util.Observable", Ext.Base,
&#13;
&#13;
&#13;

0 个答案:

没有答案