我正在尝试使用VBA和HTML单击Internet Explorer窗口中的按钮。该按钮没有“id”,因此我必须通过“classname”找到它。
按钮的HTML代码如下:
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only`"
VBA代码:
Private Sub CommandButton21_Click()
Const cURL = "xxxxxx.com"
Const cUsername = "xxxxxx"
Const cPassword = "xxxxxx"
Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputElement
Dim PasswordInputBox As HTMLInputElement
Dim SignInButton As HTMLInputButtonElement
Dim CVBATButton As HTMLInputButtonElement
Set IE = New InternetExplorer
IE.Visible = True
IE.navigate cURL
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Set doc = IE.document
'A previous login window that leads me into a new window, where I need to click a button.
Set LoginForm = doc.forms(0)
Set UserNameInputBox = doc.getElementById("BIA_Login")
UserNameInputBox.Value = cUsername
Set PasswordInputBox = doc.getElementById("BIA_Pass")
PasswordInputBox.Value = cPassword
Set SignInButton = doc.getElementById("login")
SignInButton.Click
'It's this portion of the code below that I'm struggling with
Set doc = IE.document
Set LoginForm = doc.forms(0)
Application.Wait Now + TimeValue("00:00:03")
Set CVBATButton = doc.getElementsByClassName("ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only")
CVBATButton.Click
答案 0 :(得分:1)
我有同样的错误, 尝试这个(它对我有用):
dat %>%
plot_ly(x = ~as.numeric(IC),
y = ~xval,
color = ~gene,
type = "box",
hoverinfo = "none"
) %>%
add_markers(x = ~jitter(as.numeric(gene_x_covariate)),
y = ~xval,
color = ~gene,
marker = list(size = 3),
hoverinfo = "text",
text = txt,
showlegend = TRUE) %>%
layout(boxmode = "group")
答案 1 :(得分:0)
getElementsByClassName
返回一个集合。您将需要访问第一个索引,或迭代该集合。
Set CVBATButton = doc.getElementsByClassName("ui-button ui-widget ...")(1)
CVBATButton.Click