gpt4 book ai didi

VBA [Internet Explorer] - 按钮提交(登录)

转载 作者:行者123 更新时间:2023-12-04 21:21:44 25 4
gpt4 key购买 nike

我需要一些关于如何通过 VBA 代码按下按钮的指导。这是在使用下面的代码之前完成的:(请参阅注释“<-----”,看看我卡在哪一行。)

WWW = "http://sezv... ' I can't provide the address since it is on a server.

Set IE = New InternetExplorerMedium
IE.Visible = True
IE.Navigate WWW
StartDate & EndDate

Do
If IE.READYSTATE = 4 Then
Exit Do
Else
DoEvents
End If
Loop

With IE.Document
.getElementById("Username").Value = "Test" 'Username
.getElementById("Password").Value = "Test2" 'Password
.all("Logga in").Click ' <---------
End With

HTML 看起来像这样:
<input name="Logga in" class="button right" type="submit" value="Logga in"/>
我将如何使用看起来像这样的按钮来执行此操作?:
<button class="REGISTRATION_FORM-Button" style="border-top-color: currentColor; border-right-color: currentColor; border-bottom-color: currentColor; border-left-color: currentColor; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; background-image: url("http://sezvm1091:9090/ais/images/buttonBackground.gif"); background-attachment: scroll; background-repeat: no-repeat; background-position-x: 0px; background-position-y: -50px; background-size: auto; background-origin: padding-box; background-clip: border-box; background-color: transparent;" type="button">

据我所知,这可能与某些脚本有关,如果是,我能否获得一些指导以了解如何找到它并将其实现到上面的代码中?
我很想分享脚本代码,但它是 70207 行。

最佳答案

要找到您可以使用的按钮,例如querySelector您可以在其中指定元素名称和类名称。

Dim btn As HTMLButtonElement
Set btn = IE.document.querySelector("button[class=REGISTRATION_FORM-Button]")
btn.Click

如果有更多具有相同类的按钮,如下所示:
<button title="Klarmarkera (ctrl+K)" class="ACTION_BUTTON-Button" style="border-top-color" type="button" >Klarmarkera (ctrl+K)</button>
<button title="Nytt samtal (ctrl+S)" class="ACTION_BUTTON-Button" style="border-top-color" type="button" >Nytt samtal (ctrl+S)</button>

那么更多的属性可以用于 querySelector例如 title :
Set btn = IE.document.querySelector("button[class=ACTION_BUTTON-Button][title='Nytt samtal (ctrl+S)']")

如果出现更多类名,如下所示:
<button class="FancyButton FancyButton-ACTION_FORM-Button" style="border-top-color" type="button">Fancy Form Button</button>
querySelector可能看起来像这样:
Set btn = IE.document.querySelector("button[class='FancyButton FancyButton-ACTION_FORM-Button']")

关于VBA [Internet Explorer] - 按钮提交(登录),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43652353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com