UPS自动跟踪单击按钮 [英] UPS Automated tracking clicking a button

查看:188
本文介绍了UPS自动跟踪单击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问网页。然后在测试框中输入一个数字。我能够做到这一点。

I want to visit webpage. Then enter a number in test box. I was able to do that.

之后,我想点击跟踪按钮。任何想法如何点击通过vba?

after that I want to click on the Track Button. Any idea how can I click through vba?

我已经尝试过下面的命令。任何想法如何查找跟踪按钮的id?

I already tried below commands. Any idea how can i find id of the Track button?

ie.document.getElementByName("track.x").Click
ie.document.getElementByClass("button btnGroup6 arrowIconRight").Click

输入跟踪号1ZW2E2360449018801,一旦我点击该按钮,就会打开一个新网页。我想点击发货进度栏,并复制出现的表。任何建议?

Lets say we enter the tracking number "1ZW2E2360449018801" and once I click that button, a new webpage opens. I want to click on "shipment Progress" bar and copy the table that appears. any suggestions?

推荐答案

这将得到它。

Sub test()
' open IE, navigate to the website of interest and loop until fully loaded
    Set ie = CreateObject("InternetExplorer.Application")
    my_url = "http://wwwapps.ups.com/WebTracking/track?loc=en_US"

    With ie
        .Visible = True
        .navigate my_url
        .Top = 50
        .Left = 530
        .Height = 400
        .Width = 400

    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop

    End With

' Enter a value in the "Number" text box
    ie.Document.getElementById("trackNums").Value = "1ZW2E2360449018801"

' Click the "Submit" button
    Set Results = ie.Document.getElementsByTagName("input")
    For Each itm In Results
        If InStr(1, itm.outerhtml, "Track", vbTextCompare) > 0 Then
            itm.Click
            exit for
        End If
    Next

' Click the "Shipment Progress" button
    Set Results = ie.Document.getElementsByTagName("h4")
    For Each itm In Results
        If InStr(1, itm.outerhtml, "Shipment Progress", vbTextCompare) > 0 Then
           itm.Click
           exit for
        End If
    Next

' Get the text from the "Shipment Progress Table" and assign to a variable
    tbltxt = ie.Document.getElementsByTagName("table")(4).innertext

    ' process the text as desired
End Sub

这篇关于UPS自动跟踪单击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆