【问题标题】:IE VBA open web page equal to clicking on first web page linkIE VBA打开网页等于点击第一个网页链接
【发布时间】:2018-05-05 20:53:03
【问题描述】:

我正在尝试使用 Internet Explorer 和 MS-Access VBA 在一系列网页上自动填写交易。我已经做了很多这样的事情,但我被这一对页面难住了。我使用这样的代码:

Set htmlDoc = ie.Document
With htmlDoc
    Set e = .getElementById("j_idt31_data")
    If e Is Nothing Then GoTo FileAppeal_Error
    Set elems = e.getElementsByClassName("ui-widget-content ui-datatable-odd ui-datatable-selectable")
    For Each e In elems
        If InStr(1, e.innerText, "Evans ") > 0 Then
            e.Click
            Exit For
        End If
    Next

结束

我从这个页面开始: https://boe.shelbycountytn.gov/eFile/taxrep.xhtml, 单击左侧的单选按钮之一,然后单击 [提交],这将带我到 https://boe.shelbycountytn.gov/eFile/search.xhtml

但我不知道如何以编程方式让 [提交] 按钮成功。当我以编程方式单击它时,我收到“需要税务代表”错误消息。

非常感谢您的建议。

【问题讨论】:

    标签: vba internet-explorer


    【解决方案1】:

    我使用selenium basic 完成了这项工作。下载并添加 selenium 类型库参考。

    Option Explicit
    Public Sub test()
        With New ChromeDriver
             .Start "Chrome"
             .Get "https://boe.shelbycountytn.gov/eFile/taxrep.xhtml"
             .FindElementByCss("span.ui-radiobutton-icon.ui-icon.ui-icon-blank").Click
             .FindElementByCss("span.ui-button-text.ui-c").Click     
        'other code
        Stop
        .Quit
        End With
    End Sub
    

    【讨论】:

    • 非常有帮助。我过去使用过 Selenium Basic,但这个项目几乎是使用 MSHTML.HTMLDocument 完成的。不过,按照你的逻辑,我能够让它工作: Set elems = HTMLDocument.getElementsByClassName("ui-icon-blank") Set i = elems(1) i.Click
    • 抱歉 - 无法让代码格式在 Comment 中工作。请参阅下面的代码块。
    • 我确实看到并赞成 :-) 我一直在搞砸硒,因此沿着这条路走下去。道歉但没有阻止你:-)
    【解决方案2】:
        Dim elems As MSHTML.IHTMLElementCollection, i As MSHTML.HTMLInputElement        
        Set elems = HTMLDocument.getElementsByClassName("ui-icon-blank")
        Set i = elems(1) 'this gets the second option in the list
        i.Click
    

    【讨论】:

      猜你喜欢
      • 2010-10-17
      • 2020-06-28
      • 1970-01-01
      • 1970-01-01
      • 2015-09-14
      • 1970-01-01
      • 1970-01-01
      • 2014-04-03
      • 2018-08-01
      相关资源
      最近更新 更多