zoukankan      html  css  js  c++  java
  • Excel控制IE

    ---恢复内容开始---

    1、初始化and连接http网页

    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    ie.navigate "http://10.251.68.38:8088/....."
    Do Until ie.Readystate = 4
        DoEvents
    Loop

    2、索引对象

      1.by id/name(getElementById搜索时包揽id、name)
    ie.Document.getElementById("name").Value = "aaa"
       2.by tagName
    For i = 0 To ie.Document.All.Length - 1
        If UCase(ie.Document.All(i).tagName) = "INPUT" Then
            If UCase(ie.Document.All(i).Type) = "IMAGE" Then
                ie.Document.All(i).Click
                Exit For
            End If
        End If
    Next
      3.访问frame内元素
    For k = 0 To ie.Document.frames.Length - 1
        For i = 0 To ie.Document.frames(k).Document.All.Length - 1
            If UCase(ie.Document.frames(k).Document.All(i).tagName) = "A" Then
                ss = ie.Document.frames(k).Document.All(i).href
                If InStr(1, ss, "menuID=201", vbTextCompare) > 0 Then
    '            If ie.Document.frames(k).Document.All(i).href = "../inventory/searchInv.jsp?menuID=201" Then
                    ie.Document.frames(k).Document.All(i).Click
                    Exit For
                End If
            End If
        Next
    Next

    3、读取、修改元素属性

     元素各个属性能直接访问,如

    ie.Document.All(“name”).Value
    
    ie.Document.All(i).scr
    
    ie.Document.All(i).href
  • 相关阅读:
    C#设计模式-单例模式
    MVC图片上传并显示缩略图
    asp.net MVC发布iis无法加载css,js和图片
    Silverlight中获取控件中子控件
    Lambda加自定义比较器实现两个列表的合并
    MVC文件上传
    pt-osc测试
    MySQL DDL方案测试及选型.
    gh-ost测试
    gh-ost原理
  • 原文地址:https://www.cnblogs.com/lulu147/p/5653736.html
Copyright © 2011-2022 走看看