简体   繁体   中英

Trigger click on href button with js or vbs

my goal here for my users to be able to access the page they need without having to passe trough 3 different pages and clicking all sorts of button to get there. i was able to find on this website how to do it for the http://www.cra-arc.gc.ca/esrvc-srvce/tx/bsnss/gsthstrgstry/menu-fra.html website. now i'm trying with this website : http://www.revenuquebec.ca/fr/sepf/services/sgp_validation_tvq/default.aspx but the thing is that on the second website the button is not coded the same way so my script doesn't work with it and i don't know how to adapt my script for it to work

here's the script i have that works perfecly fine with the first link

Call test
Sub test()
With CreateObject("InternetExplorer.Application")

    .Visible = True
    .Navigate "http://www.cra-arc.gc.ca/esrvc-srvce/tx/bsnss/gsthstrgstry/menu-fra.html"

    Do While .Busy Or .readyState <> 4
        WScript.Sleep 50
    Loop

    Set oInputs = .Document.getElementsByTagName("input")

    For Each elm In oInputs
        If elm.Value = "J'accepte" Then
            elm.Click
            Exit For
        End If
    Next

    Do While .Busy Or .readyState <> 4
        WScript.Sleep 50
    Loop
End With
End Sub

here's the difference:

first site : uses "value = J'accepte"

second site : uses "title="Accès au service", class="bouton_acces_fr" and href="javascript:SoumettreParam('S00047','F')"

so in the script i use "J'accepte" to trigger the click in the website, but in the second one "value" does not exist and i see to "id" for the button thanx !

but in the second one "value" does not exist and i see to "id" for the button

If elm.Value <> "J'accepte" Then
   elm.Click

Would be the simplest solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM